Mermaid diagrams
To add a Mermaid diagram to Markdown, write the diagram as text inside a fenced code block tagged mermaid. Apps that support Mermaid draw the diagram in place of the code; apps that do not show the code as an ordinary code block. Mermaid is a separate diagram language, not part of CommonMark or GitHub Flavored Markdown (GFM).
flowchart LR
A[Write notes] --> B[Review]
B --> C{Ready?}
C -->|Yes| D[Publish]
C -->|No| A
In an app that supports Mermaid, that block renders as a left-to-right flowchart with a decision diamond and a loop back to the start.
How do you write a flowchart?
Start with flowchart and a direction, then one connection per line. The direction is TD or TB for top to bottom, LR for left to right, RL or BT for the reverse.
flowchart TD
start([Request received]) --> check{Valid?}
check -->|Yes| save[(Database)]
check -->|No| reject[Return error]
- The text before a bracket is the node's ID; the text inside is its label.
- The bracket shape sets the node shape:
[ ]rectangle,( )rounded,([ ])pill,{ }diamond,[( )]cylinder. -->is an arrow,---a plain line,-.->a dotted arrow, and-->|label|puts text on the arrow.- Older files often use
graph TDinstead offlowchart TD, which still works.
How do you write a sequence diagram?
Start with sequenceDiagram, then one message per line in the form Sender->>Receiver: message. Each participant becomes a column with a lifeline.
sequenceDiagram
participant U as User
participant A as App
participant S as Server
U->>A: Click save
A->>S: POST /notes
S-->>A: 201 Created
A-->>U: Show "Saved"
->> is a solid arrow for a request and -->> a dotted arrow, used for replies. participant lines are optional, but they fix the column order and let you use short aliases.
Mermaid also supports class diagrams, state diagrams, Gantt charts, pie charts, entity relationship diagrams and more; the Mermaid documentation lists each type with its syntax.
Where do Mermaid diagrams render?
| Where | Renders Mermaid |
|---|---|
| GitHub | Yes, in .md files, issues, pull requests, discussions and wikis |
| GitLab | Yes, in Markdown files and comments |
| Obsidian | Yes, in reading view and live preview |
| VS Code | Not in the built-in preview; yes with a Mermaid preview extension |
| Noteline | Yes, in the editor as you type |
| Plain CommonMark renderers | No, the code shows as a code block |
GitHub documents Mermaid support for issues, discussions, pull requests, wikis and Markdown files (GitHub Docs, checked November 2026). Because each app bundles its own Mermaid version, a newer diagram type may work in one app and fail in another. GitHub suggests a mermaid block containing only info to see which version it uses.
Why is my Mermaid diagram not rendering?
- The block is tagged
Mermaid,mmdor nothing. Use lowercasemermaidafter the opening fence. - There is a syntax error. Most apps show an error message instead of the diagram; check the line it names.
- A node is named
endin lowercase, which closes a block in flowchart syntax. WriteEndorEND. - Labels contain characters such as parentheses or quotes. Wrap the label in double quotes:
A["Step (optional)"]. - The app does not support Mermaid at all, or uses an older version without that diagram type.
Mermaid diagrams in Noteline
Noteline renders mermaid code blocks as diagrams in place while you write. Move the cursor into the block to edit the source, and the diagram redraws when you leave it. Diagrams follow the light or dark theme. The file keeps the plain text block, so the same diagram renders on GitHub or GitLab when you push the file.
Common questions
Is Mermaid part of Markdown?
No. Mermaid is its own diagram language. Markdown only provides the fenced code block that holds it, and the app decides whether to draw it.
Can I export a Mermaid diagram as an image?
Not from plain Markdown itself. The Mermaid Live Editor at mermaid.live can export a diagram as SVG or PNG, and the Mermaid command line tool converts diagram files to images.
Do I need to install anything to use Mermaid?
Not in apps that already support it, such as GitHub, GitLab, Obsidian or Noteline. In VS Code you need an extension for the preview.