Example
sankey-beta
Traffic Sources,Visitors,1000
Organic Search,Visitors,400
Direct,Visitors,300
Social Media,Visitors,200
Referral,Visitors,100
Visitors,Opened Editor,650
Visitors,Read Cheatsheet,200
Visitors,Bounce,150
Opened Editor,Shared Link,180
Opened Editor,Exported PNG,290 Syntax
Flows
sankey-beta
Visitors,Signed up,320
Visitors,Bounced,680
Signed up,Activated,210
Signed up,Churned,110
Activated,Paid,60
Activated,Free,150 Three comma-separated columns per line, no header. Node names repeat across lines to form stages. Quote a name that contains a comma: "Acme, Inc.",Revenue,100.
Common mistakes
These are the parse errors that come up most, including in code written by ChatGPT and Claude. Paste any failing diagram into the editor and it marks the offending line.
-
Spaces after commas (
A, B, 10).Fix: Mermaid trims them in recent versions, but older renderers (including some GitHub deployments) do not. Write
A,B,10. -
A cycle (
A,B,5andB,A,3).Fix: Sankey layouts require a directed acyclic graph. Model the return flow as a separate node (
A,B,5andB,A-return,3). -
Inconsistent node spelling (
Sign upvsSignup).Fix: Each distinct string is a separate node. Copy names exactly.
Real-world examples
Complete, copy-ready sankeys for common situations. Each one opens in the editor with a click.
Browse all examples →FAQ
Can I control node order or colours?
Order is computed by the layout. Colours come from the theme; MermanDraw's Dark and Neon themes give high-contrast bands for presentations.
Does the diagram need values to sum up at each node?
No. Mermaid draws each link independently, so inflow and outflow can differ. That is useful for showing loss between stages.