Mermaid in a minute
Five lines make a flowchart:
- The first line names the diagram type and, for a flowchart, its direction:
flowchart LRruns left to right,flowchart TDtop down. - Each box has an id and a label:
A[Order placed]. The brackets set the shape:[ ]a box,( )rounded,{ }a decision,(( ))a circle. - An arrow joins two ids:
A --> B. Put a label on it with-->|yes|.-.->draws a dotted line and==>a thick one. - Reuse an id to point at the same box again:
B -->|no| D[Send reminder].
- Wrap a label in quotes when it has brackets or other punctuation:
A["Pay (card)"]. - Group boxes with
subgraph Payments…end. - A line starting
%%is a comment, which the drawing ignores. - Indenting is optional, but makes the code easier to read.
flowchart LR
A[Order placed] --> B{Paid?}
B -->|yes| C[Ship order]
B -->|no| D[Send reminder]
C --> E((Done))Other types start with their own first line:
flowchart LR: Flowchart (also graph); LR, RL, TD, TB, or BT sets the direction (Flowchart cheat sheet).sequenceDiagram: Sequence diagram (Sequence diagram tutorial).classDiagram: Class diagram (Class diagrams).stateDiagram-v2: State diagram (State diagrams).erDiagram: Entity relationship (ER) diagram (ER relationship cheat sheet).architecture-beta: Architecture diagram, with cloud icons.gantt: Gantt chart.mindmap: Mind map.timeline: Timeline.journey: User journey.pie: Pie chart.gitGraph: Git graph.
Quadrant charts, Sankey, XY and block diagrams, packet diagrams, Kanban boards, requirement and C4 diagrams work too. Cards with icons, subtitles, and badges are written inside ordinary labels: see Rich nodes and icons. For every type’s full syntax, see the Mermaid reference.