Mermaid diagrams in Markdown
Updated
Mermaid turns a few lines of text into a diagram. You write the text in a code block marked mermaid, and apps that support it draw the picture. Because the source is text, the diagram lives in the same file as your notes and changes show up in version control.
- Start a code block with
```mermaidand write the diagram inside. - In the editor, the diagram is drawn under the code and redrawn as you type.
- The exported
.mdkeeps the text. Word, PDF and shared links get the drawn picture.
A first diagram
```mermaid
flowchart TD
A[Draft] --> B{Reviewed?}
B -- Yes --> C[Publish]
B -- No --> A
```
flowchart TD means a flowchart drawn top-down; LR draws it left to right. Square brackets make a box, curly brackets a decision, and --> an arrow. Text between two dashes labels the arrow.
The diagram types people use most
Sequence diagram
```mermaid
sequenceDiagram
Browser->>Server: Sign in
Server-->>Browser: Session cookie
Browser->>Server: Save notes
```
Gantt chart
```mermaid
gantt
dateFormat YYYY-MM-DD
section Launch
Write copy :a1, 2026-01-05, 5d
Design :a2, after a1, 4d
Review :after a2, 2d
```
Pie chart
```mermaid
pie title Where the time goes
"Writing" : 55
"Editing" : 30
"Formatting" : 15
```
Mermaid also has class diagrams, state diagrams, entity-relationship diagrams, mind maps and timelines. The syntax for each is in the Mermaid documentation.
Writing diagrams in RichMarkdown
- Open the editor. On an empty line, type
```mermaidand press Enter. This starts a code block marked as Mermaid. - Or paste or open Markdown that already has a
mermaidblock. - Write the diagram. It is drawn under the code a moment after you stop typing.
- If the text has a mistake, the error message is shown in place of the picture, and the code stays as you wrote it.
The diagram library is loaded only for notes that contain a diagram, and it runs in your browser. The diagram text is not sent anywhere.
Where the diagram goes next
| Destination | What arrives |
|---|---|
| Export .md | The mermaid code block, unchanged. |
| Download Word (.docx) and Copy for Word | The drawn diagram as a picture. It cannot be edited in Word; keep the Markdown as the source. |
| Save as PDF / print | The drawn diagram, without the code. |
| A shared link | The drawn diagram. |
| GitHub, GitLab, Obsidian | They draw mermaid blocks themselves. |
| Apps without Mermaid | The text is shown as a code block. |
Common mistakes
- Brackets or quotes in a label. Wrap the label in double quotes:
A["Cost (USD)"]. - The word
endas a node name. It is reserved in flowcharts. WriteEndor put it in quotes. - Missing diagram type. The first line must name it:
flowchart TD,sequenceDiagram,gantt,pie. - A plain code block. Without the
mermaidlanguage on the block, it is ordinary code and nothing is drawn.
Related guides
FAQ
Do I need to install anything?
No. The diagram is drawn in your browser.
Is my diagram uploaded?
No. The drawing happens on your device. Nothing is sent unless you share the note as a link or turn on cloud save.
Can I edit the diagram in Word?
No. Word receives a picture. Change the Mermaid text here and export again.
Does GitHub show Mermaid diagrams?
Yes. GitHub draws mermaid code blocks in README files, issues and comments.
Why is my diagram shown as code?
The code block is not marked as mermaid, or the app that displays it does not support Mermaid.