How to use
- Paste a JSON array: of objects (most common), or of arrays.
- Pick the Field separator if you need semicolon or tab instead of comma.
- Read the result: the first row is the header (the union of every object's keys, in the order they first appear), one data row per array item.
- Copy to clipboard, or Download .csv to open directly in a spreadsheet.
Turning nested JSON into flat rows
A JSON array of objects and a CSV file describe the same shape (one row per item, one column per field), but JSON allows each object to have different keys, nested objects, and arrays, none of which CSV can represent directly. This tool reconciles the two: it collects every key that appears anywhere in the array into one header row, fills in a blank for any object missing a key, and serialises a nested object or array as a JSON string inside its cell rather than dropping it. Going the other way, the CSV to JSON Converterturns a spreadsheet export back into structured JSON.
Example
This JSON array:
[
{
"name": "Ada Lovelace",
"age": 28,
"city": "London"
},
{
"name": "Grace Hopper, PhD",
"age": 85,
"city": "New York, NY"
}
]becomes:
name,age,city
Ada Lovelace,28,London
"Grace Hopper, PhD",85,"New York, NY"Options explained
- Field separator: Comma / Semicolon / Tab. Use semicolon for CSV meant to open correctly in Excel set to a European locale (which treats comma as the decimal separator), or tab for a
.tsvfile. - Load sample inserts the array above; Clear empties the box.
Edge cases and common errors
- The top level must be an array. A single object,
{"a": 1}, stops with "The top level must be a JSON array, of objects or of arrays"; wrap it in[ ]if you meant one row. - Every item must be the same shape. Mixing objects and non-objects, like
[1, {"a": 2}], stops with "Every item must be the same shape: all objects, or all arrays, not a mix" rather than guessing which rows to keep. - An empty array (
[]) produces empty output rather than an error, since there is nothing to derive a header from. - Missing keys and nested values: see the FAQ.
- Quoting follows RFC 4180 exactly:
{"note": "hello, \"world\""}becomes a single correctly-quoted cell,note "hello, ""world""", not two broken columns.
Do the same thing in code
import csv, json, sys
rows = json.load(open("data.json"))
keys = list(dict.fromkeys(k for row in rows for k in row))
w = csv.DictWriter(sys.stdout, fieldnames=keys)
w.writeheader()
w.writerows(rows)Python's csv.DictWriter needs the full field list up front (dict.fromkeysabove collects the same union-of-keys this tool computes automatically) and, like this tool, turns anything that isn't already a string into its str() form rather than a JSON string. Pre-serialise nested values with json.dumps first if you need this tool's exact behaviour.