JSON to CSV

Paste or upload a JSON array to flatten it into a CSV file. Runs in your browser.

Pasted text and chosen files stay on this device. Nothing is sent to a server.

Drop a file here, choose one, or paste.

No output yet Convert to see the result here.

How to use it

  1. 1

    Paste the array.

  2. 2

    Check the column list before downloading — flattening is where the surprises are.

What it does

JSON is a tree and CSV is a grid, so this is a lossy conversion by construction. The interesting decisions are all about what to do with the parts of the tree that do not have a column: flatten, serialise, or drop.

Take an array of objects, collect the union of their keys as columns, and write one row per object. Nested objects and arrays are flattened with a separator, or serialised as text, as chosen. Report rows and columns written.

Why it works this way

The header is the union of every object's keys, not the first object's. Using the first object silently drops columns that only appear later, and the output still looks like a complete table.

Nothing is dropped silently. If a value cannot be represented — an array inside a cell, a nested object with the separator already in a key — it is either serialised or reported, never quietly removed.

The row and column counts are printed because a conversion that produced "a CSV" is not the same as one that produced the rows you expected.

Examples

[{"a":1,"b":{"c":2}}]
a,b.c\n1,2
the nested member becomes a column named for its path
[{"a":1},{"b":2}]
a,b\n1,\n,2
the header is the union; each row leaves the other column empty

Inputs and outputs

  • JSON (array of objects, or one object)
  • nested values: flatten with a separator / serialise as text
  • missing keys: empty cell / omit the row
  • CSV text
  • rows and columns written
  • the columns that came from flattening rather than from a top-level key

Edge cases

  • ragged objects — union header, empty cells
  • an array of scalars rather than objects
  • a nested object whose key contains the separator
  • numbers and strings that look alike
  • empty array — header only, zero rows

Frequently asked questions

Why does my CSV have more columns than the first object?

The header is the union of all objects' keys. Using the first object alone would drop columns that appear only in later rows.

What happens to an array inside a value?

It is serialised into the cell as JSON text, and the column is listed as flattened so you know which ones those are.

Related tools

Sources

  • RFC 4180, Common Format and MIME Type for CSV Files