CSV to Sankey Diagram: The Source, Target, Value Format

A Sankey diagram needs three columns: source, target and value. See the CSV layout, a worked funnel example and how to turn the file into an editable diagram.

The standard way to describe a Sankey diagram as data is a list of flows, one per row, with three columns: where it starts, where it ends and how much.

That format is the same in most Sankey tools, which makes a CSV the easiest thing to move between them. Every distinct name that appears as a source or a target becomes a node, and each row becomes one ribbon whose width is the value.

The example is a signup funnel. Its CSV below is short enough to read in one go, and it shows the two habits that make Sankey data work: every row has a positive number, and every stage that loses people shows the loss as its own flow instead of silently dropping it.

How to read this diagram

  • One row is one ribbon. The first column names where it starts, the second where it ends, the third how wide it is.
  • Values must be positive numbers. A negative amount is refused and a zero draws no ribbon.
  • Use one spelling per node. "Signup" and "Sign-up" would become two different nodes.
  • Show losses as flows to their own node. Here, of 1,200 visitors, 120 sign up and 1,080 leave; both are rows.

The data behind it

Invented funnel counts: 1,200 visitors, 120 sign-ups, 65 trials and 21 paying customers.

CSV to Sankey Diagram: The Source, Target, Value Format (visitors)
FromToAmount (visitors)
Website visitSigned up120
Website visitLeft without signing up1080
Signed upStarted trial65
Signed upNever started55
Started trialBecame paying21
Started trialTrial ended44

The same data as CSV

source,target,value
Website visit,Signed up,120
Website visit,Left without signing up,1080
Signed up,Started trial,65
Signed up,Never started,55
Started trial,Became paying,21
Started trial,Trial ended,44

How it works

  1. Write one flow per row

    Create columns named source, target and value, and put each flow on its own row. Save as CSV, or copy the cells straight from a spreadsheet.

  2. Paste it into a new Sankey

    Open a new Sankey chart in QueryChart, choose Paste a list of flows and paste the rows. Each name becomes a node, and each row becomes a flow with its amount.

  3. Read the warnings

    Check any node that sends out more than it receives, fix the typo or the spelling, and then style the diagram.

Frequently asked questions

What columns does a Sankey CSV need?

Three, in this order: source, target and value. A header row is optional, and a unit can be written in the value header, as in value (GWh). Extra columns are ignored.

Which separators and number formats work?

Commas, semicolons and tabs (a copy from Excel or Google Sheets is tab-separated). Quote a name that contains the separator. The same source and target listed twice are added together, and a line without a positive number is left out.

Can a Sankey CSV contain loops?

A flow that leads back to an earlier node is a loop. QueryChart flags it, and a diagram with loops is hard to read, so split the node instead: send rework to a separate Rework node.

Can values be negative or zero?

No. A ribbon needs a positive width: a negative amount is refused and a zero draws nothing. Model a decrease as a flow to a node such as Lost or Returned.

Turn your CSV into a Sankey diagram

Opens a new Sankey chart with a place to paste your source, target and value rows.

Turn your CSV into a Sankey diagram

More in Sankey diagrams