Going Stellar

Home/Methods

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

WhereWhat it rendersNote
GitHubIssues, discussions, pull requests, wikis and Markdown filesthird-party Mermaid plugins can cause errors
GitLabMarkdown in issues, merge requests, wikis and filesMermaid 12
Obsidianmermaid code blocks in notesinternal links via a class
VS Codethe built-in Markdown previewpan, 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

  1. GitHub Docs: Creating diagrams
  2. GitLab Docs: GitLab Flavored Markdown, Diagrams and flowcharts
  3. Obsidian Help: Advanced formatting syntax, Diagram
  4. Visual Studio Code: Markdown and Visual Studio Code
  5. Mermaid documentation: Accessibility options
  6. Mermaid documentation: Integrations
  7. 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/

Read as Markdown

All methods

Contact

Tell us what is not working

Write in English or Romanian. A person reads it — usually the same person who would do the work — and answers within one business day.