Mermaid Diagrams
Draw flowcharts, sequence diagrams and entity relationship diagrams from Mermaid text.
Write Mermaid in the text editor and ToDiagram draws it as you type. Flowcharts, sequence diagrams and entity relationship diagrams are supported. Files with the extension .mermaid or .mmd open as Mermaid.
Flowchart
flowchart LR
A[logos:github-icon Push to main] --> B[logos:docker-icon Build]
B --> C[logos:vitest Unit tests]
B --> D[logos:eslint Lint]
C --> E{All green?}
D --> E
E -- yes --> F[logos:kubernetes Deploy to staging]
F --> G[logos:playwright Smoke tests]
G --> H[logos:kubernetes Deploy to production]
E -- no --> I[logos:slack-icon Notify team]Open a Mermaid example in the editor
Sequence diagram
sequenceDiagram
participant U as User
participant W as Web app
participant A as Auth API
U->>W: Sign in
W->>A: POST /token
A-->>W: 200 access token
W-->>U: DashboardSupported Syntax
Supported Mermaid syntax includes:
- Flowchart:
flowchart/graphdirections (LR,TB,BT,RL), node shapes (see below), connections, and edge labels. - Sequence:
sequenceDiagramwith participants, message arrows, notes, activations, grouped blocks (loop,alt,opt,par,critical,break,rect), andautonumber. - Entity Relationship:
erDiagramwith entities, attribute blocks (types,PK/FK/UKkeys, comments), relationships with cardinalities,direction, andsubgraphgrouping.
Entity Relationship Diagrams
Entities render as cards with one row per attribute. Relationships become labeled edges showing the role and cardinality of each side, and non-identifying relationships (written with ..) render as dashed lines.
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
CUSTOMER {
int id PK
string name
string email
}
ORDER {
int id PK
int customer_id FK
date placed_at
}
LINE_ITEM {
int order_id FK
string sku
int qty
}Cardinality symbols map to readable ranges on the edge label:
| Symbol (left / right) | Meaning | Label |
|---|---|---|
|o / o| | Zero or one | 0..1 |
|| / || | Exactly one | 1 |
}o / o{ | Zero or more | 0..N |
}| / |{ | One or more | 1..N |
Notes:
- Every relationship requires a label (the
: labelsuffix), per Mermaid's grammar. - Word forms such as
one or more,zero or many,many(0),1+, andonly oneare also supported.
Node Shapes
Mermaid's short-syntax flowchart shapes render as their declared silhouette:
| Mermaid syntax | Shape |
|---|---|
A[text] | Rectangle |
A(text) | Rounded rectangle |
A([text]) | Stadium / pill |
A[[text]] | Subroutine |
A[(text)] | Cylinder |
A((text)) | Circle |
A(((text))) | Double circle |
A{text} | Diamond |
A{{text}} | Hexagon |
A[/text/] | Parallelogram (lean right) |
A[\text\] | Parallelogram (lean left) |
A[/text\] | Trapezoid |
A[\text/] | Inverse trapezoid |
A>text] | Asymmetric |
flowchart LR
Start([Start]) --> Decide{Approved?}
Decide -->|yes| Store[(PostgreSQL)]
Decide -->|no| End(((Done)))
Store --> EndEdges meet the outline of each shape, so connections touch circles, diamonds and hexagons cleanly.
Icons
Start a node's label with an Iconify icon name to put an icon on the node. The name has the form set:icon-name, for example lucide:database or logos:postgresql. A name that does not exist is not drawn.
flowchart LR
A["lucide:monitor Web app"] --> B["lucide:database Database"]Edit on the canvas
Flowcharts can be edited on the canvas as well as in the text: click a node for its details, right-click it for its toolbar, and use Swap direction in the canvas toolbar to switch between left to right and top to bottom. Every change is written back as Mermaid text. See Edit on the Diagram.
Entity relationship diagrams can be edited on the canvas too. In a sequence diagram you can double-click a message to change its text. The rest is edited as text.
Good to know
- Views other than the flow diagram and the tree, Fields, Compare and JSON Schema apply to data formats and are not available for Mermaid.
- Export works the same as for any other diagram: PNG, JPEG, SVG and MP4.