Step 1 – Choose a direction
Start your Mermaid code with graph TD for a top-down flowchart, or graph LR for a left-to-right layout. Top-down suits tall processes; left-to-right works better for wide workflows.
graph TDgraph TD = top-down, graph LR = left-to-right
Step 2 – Add nodes
Each node is an ID followed by a label in square brackets. The ID is used to reference the node in connections; the label is what appears in the diagram.
graph TD
A[Start]
B[Process data]
C[End]Three nodes with IDs A, B, C
Step 3 – Connect nodes with arrows
Use --> to draw an arrow from one node to another. You can add a label to any arrow by putting text between pipe characters.
graph TD
A[Start] --> B[Process data]
B --> C{Success?}
C -->|Yes| D[Done]
C -->|No| E[Retry]
E --> BArrows with a decision diamond and labeled branches
Step 4 – Use the right node shapes
Mermaid supports several shapes to convey meaning:
[Label] – rectangle (process step)
{Label} – diamond (decision / yes-no branch)
(Label) – rounded rectangle (start or end)
[(Label)] – cylinder (database or storage)
((Label)) – circle (connection point)
graph TD
A(Start) --> B[Validate input]
B --> C{Valid?}
C -->|Yes| D[(Save to DB)]
C -->|No| E[Show error]
D --> F(End)A complete flowchart using several node shapes
Export your flowchart
When your flowchart looks right, click Download SVG for a crisp vector image you can embed in any document, or Download PNG for a raster image ready to paste into a presentation or wiki.
You can also copy a shareable link – the diagram code is encoded in the URL, so anyone with the link sees the same diagram without needing an account.
Flowchart tips
Keep labels short – one line per node is easier to read at a glance.
Use subgraph blocks to group related steps when your chart gets large.
Start with the happy path (the normal flow), then add error branches.
Consistent direction (always TD or always LR) prevents confusing layouts.