Mermaid · Markdown
Mermaid in Markdown: GitHub, GitLab, Obsidian and VS Code
In Markdown, a Mermaid diagram is a fenced code block with the language set to mermaid. GitHub, GitLab, Obsidian and the VS Code preview draw it without a plugin. What changes from one to the next is the Mermaid version, and a few extras each of them adds.
Updated
The code block
Open a fenced code block with three backticks and the word mermaid, write the diagram, and close the block. Nothing else is needed:
```mermaid
flowchart TD
A[Write Markdown] --> B[Add a mermaid code block]
```
Where Markdown supports Mermaid, the block shows as a diagram; where it does not, it shows as code, so the text is never lost. The whole diagram inside the block:
flowchart TD
A[Write Markdown] --> B[Add a mermaid code block]
B --> C[Preview or push]
C --> D[The diagram renders]
Open this example in the editor (Markdown: a diagram in a mermaid code block).
Which tools draw it
| Where | What it renders | Note |
|---|---|---|
| GitHub | Issues, discussions, pull requests, wikis and Markdown files | third-party Mermaid plugins can cause errors |
| GitLab | Markdown in issues, merge requests, wikis and files | Mermaid 12 |
| Obsidian | mermaid code blocks in notes | internal links via a class |
| VS Code | the built-in Markdown preview | pan, zoom, copy source |
Which Mermaid version?
Each tool ships its own copy of Mermaid, so a diagram type or option added recently may work in one and not in another. GitHub's documentation suggests a block containing only info: it renders the version in use.
```mermaid
info
```
In our editor it shows v12.3.0; GitLab's documentation says it supports Mermaid 12. If a diagram works in an editor but not on your site, compare the versions first.
GitHub
Diagrams render in issues, discussions, pull requests, wikis and Markdown files. GitHub also renders geojson, topojson and stl blocks, but not PlantUML. Its documentation warns that running a third-party Mermaid plugin on GitHub can cause errors.
GitLab
GitLab renders the mermaid block in its Markdown and documents Mermaid 12. Its own examples start each diagram with accTitle and accDescr, which give the drawing a title and a description for screen readers:
flowchart LR
accTitle: Release flow
accDescr: A pull request is reviewed, merged into main and deployed.
PR[Pull request] --> R{Review}
R -- approved --> M[Merge to main]
M --> D[Deploy]
Open this example in the editor (Markdown: accessible title and description).
On GitLab Self-Managed, a Cross-Origin-Resource-Policy header set to same-site or same-origin makes diagrams fail without an error; GitLab's fix is cross-origin.
Obsidian
Obsidian draws mermaid code blocks in notes. Its extra: give nodes the internal-link class and they link to the notes with those names.
graph TD
Biology --> Chemistry
class Biology,Chemistry internal-link;
Open this example in the editor (Markdown: Obsidian internal links).
Outside Obsidian the class does nothing, so the same note still renders on GitHub, without the links. Obsidian notes that links from diagrams do not show in its graph view.
VS Code
The built-in Markdown preview (Ctrl/⌘ + Shift + V) renders Mermaid code blocks without an extension. Hover the diagram for pan and zoom controls; the context menu has Copy Diagram Source.
Confluence
Confluence Cloud does not render Mermaid on its own. Mermaid Studio for Confluence, our app, does: type /Mermaid on a page, write or paste the code with a live preview, or start from one of eight templates (flowchart, sequence, Gantt, class, ER, state, pie, mind map). The diagram follows Confluence's light or dark mode, or keeps one of five themes. Copying the SVG is free; Pro adds downloads as PNG or SVG and an AI that writes the Mermaid from a plain-English description. It runs Mermaid 11.17.2, and every example on this page renders there as written.
Limits
Every example was rendered on 29 November 2026 with Mermaid 12.3.0, the version in our editor, and with 11.17.2, the version in Mermaid Studio, in light and dark themes. The table reflects each tool's documentation as read on 29 November 2026; tools update their Mermaid on their own schedule.
Sources
- GitHub Docs: Creating diagrams
- GitLab Docs: GitLab Flavored Markdown, Diagrams and flowcharts
- Obsidian Help: Advanced formatting syntax, Diagram
- Visual Studio Code: Markdown and Visual Studio Code
- Mermaid documentation: Accessibility options
- Mermaid documentation: Integrations
- Atlassian Marketplace: Mermaid Studio for Confluence (version 3.10.0)
Questions and answers
How do I add a Mermaid diagram to a GitHub README?
Write the diagram inside a fenced code block that starts with ```mermaid. GitHub renders it when the file is viewed.
Does VS Code need an extension for Mermaid?
Not for the preview: the built-in Markdown preview renders mermaid code blocks.
Why does my Mermaid diagram work in the editor but not on GitHub?
The two probably run different Mermaid versions. A block containing only info shows the version GitHub uses.
Can I link Obsidian notes from a Mermaid diagram?
Yes: add class NodeA,NodeB internal-link; and the nodes link to the notes with those names.
How to cite this
Going Stellar (2026). Mermaid in Markdown: GitHub, GitLab, Obsidian and VS Code. GOING STELLAR S.R.L..
https://goingstellar.ro/methods/mermaid-in-markdown-github-gitlab-obsidian-vscode/