Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
All diagram types

Mermaid Sankey Diagram Syntax & Flow Examples

A Sankey diagram shows how a quantity splits. The width of each band is the value you write on that line.

Examples

Copy an example, or open it in the live editor with this diagram already loaded.

Signup funnel

Each line is one hop and its count. Visits splits into Signup and Bounce, then Signup splits again.

sankey-beta

Visits,Signup,40
Visits,Bounce,60
Signup,Paid,15
Signup,Free,25

Budget allocation

A single source splits into teams. The numbers are the weights, so they can be dollars or percentages.

sankey-beta

Budget,Engineering,50
Budget,Support,20
Budget,Marketing,18
Budget,Operations,12

Content traffic

Two sources feed one node, and that node splits again. A node may have any number of inputs and outputs.

sankey-beta

Search,Docs,30
Social,Docs,10
Docs,Editor,28
Docs,Exit,12

What is a Sankey Diagram?

A Mermaid Sankey diagram is a list of weighted flows. After sankey-beta, each line is Source,Target,Value. The value sets the thickness of the band from source to target. A node can have several incoming and outgoing lines; Mermaid stacks them. Quote a name that contains a comma. There is no axis and no time. Use a Sankey when the question is where a quantity goes. Use a flowchart when the question is what happens next.

When to use it

Use a Sankey for funnels, energy splits, budget allocation, and traffic that divides across pages. Use a pie chart when each part is a share of one whole and nothing flows onward. Use an XY chart for a series of measurements.

Edit this sankey diagram in the live editor, read the Mermaid cheat sheet, or compare it with Flowchart, Pie Chart and Mind Map.

Common Use Cases

  • •Energy flow analysis - Visualize energy production, distribution, and losses
  • •Budget allocation - Show how money flows through an organization
  • •Website traffic flow - Display user navigation paths and drop-offs
  • •Supply chain mapping - Track material flow from source to destination
  • •Conversion funnels - Visualize marketing or sales pipeline quantities

Syntax Quick Reference

ElementSyntaxDescription
FlowSource,Target,ValueDefine a flow between nodes
Quoted names'Node Name',Target,10Use quotes for names with spaces
Multiple flowsOne per lineEach line defines a flow

Syntax tips

  • •Leave a blank line after sankey-beta. Each flow is then one CSV line: Source,Target,Value.
  • •The value is a number. Wider bands are larger numbers. The unit is up to you.
  • •Repeat a node name to give it another input or output. Matching names are the same node.
  • •Quote a label that contains a comma. Avoid commas otherwise, because the comma separates the three fields.
  • •There is no header row. The first line of data is a flow, not column titles.

Common mistakes

Putting spaces around the idea of a header, or adding Source,Target,Value as a first row.

Do not add a header. The first data line is a real flow, and a header would become a node named Source.

Using a comma inside an unquoted node name.

The comma is the field separator. Rename the node or quote it so the line still has three fields.

Choosing a Sankey when nothing is actually flowing onward.

A single split with no second hop is usually clearer as a pie chart.

Export Options

Sankey diagrams are wide. SVG keeps the bands clean at large sizes. Free PNG exports include a watermark.

Got Mermaid code from ChatGPT? Paste it here to render and export instantly.

Get the Free Mermaid Syntax Cheat Sheet

Free Mermaid Syntax Cheat Sheet

All 21 diagram types in one PDF reference.

Frequently Asked Questions

Ready to create your own sankey diagram?

Open the editor with this example pre-loaded and start customizing.

Sankey Diagram templates

Related Diagram Types

All diagram types