JSON array to CSV — one array, one table
Most APIs answer with a JSON array. This turns it into a flat table — plus the jq and Python one-liners if you would rather do it in a terminal.
The jq and Python one-liners
Two short versions of the same job. jq is the fastest when it is already on your machine, and Python is the one that always works.
# Every object in the array becomes one CSV row.
jq -r '.[] | [.order_id, .customer, .total] | @csv' orders.json > orders.csv
jq - pick the fields you want, straight into a CSV file
import csv
import json
with open("orders.json", encoding="utf-8") as f:
items = json.load(f)
# Accept both a bare array and a single object.
rows = items if isinstance(items, list) else [items]
fieldnames = list(dict.fromkeys(k for row in rows for k in row))
with open("orders.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=fieldnames, restval="")
writer.writeheader()
writer.writerows(rows)
Python - the standard library version
The @csv filter in jq is the part people miss: it quotes and escapes each field for you, so a name containing a comma does not split the row in two. In Python, csv.DictWriter does the same job.
Neither snippet cares what the array elements look like as long as they are objects with the same keys. When the keys differ from row to row, the nested objects tool keeps every value instead of dropping the extras.
A worked example
A three-element array of objects, and the three-row table it becomes.
orders.json
[
{"order_id": 1001, "customer": "Ada Lovelace", "total": 42.5},
{"order_id": 1002, "customer": "Grace Hopper", "total": 17},
{"order_id": 1003, "customer": "Alan Turing", "total": 99.99}
]
orders.csv
order_id,customer,total
1001,Ada Lovelace,42.5
1002,Grace Hopper,17
1003,Alan Turing,99.99
Three elements, three rows, and the header taken from the keys. The converter above defaults to a tab delimiter so the file pastes straight into Excel - switch it to comma in the settings to match this example. The array order is preserved, which matters when the array is already sorted the way you want the sheet.
Convert the array in the browser
The converter above takes exactly this input and gives you the same table.
-
Paste the array
The whole document, starting with the opening square bracket. If you paste a single object instead, the converter wraps it for you.
-
Check the preview
The row and column counts appear under the table so you can see at a glance that nothing was lost.
-
Change the delimiter if needed
Tab is the default for pasting into Excel. Pick comma for a standard .csv that other programs expect.
-
Download
One click writes the file with a .csv extension and the right encoding.
Built for real API responses
The shapes that actually come back from an API, handled properly.
One row per element
The array order is kept, so a paginated API response keeps its ordering in the sheet.
Union of keys
When later objects carry extra fields, they are kept as additional columns instead of being dropped.
Live preview
The table updates on every keystroke, so you can see the result before you download anything.
Stays on your machine
Parsing happens in the browser tab. Your payload is never posted to a server.
The full JSON to CSV guide
Everything about turning API payloads into flat tables - flattening rules, delimiters, quoting and encoding.
Related tools: CSV to JSON converter · JSONL to CSV · JSON to CSV in Python · JSON to Excel
Frequently asked questions
The short version of everything people ask about JSON arrays.
What does a JSON array look like?
[{"id": 1}, {"id": 2}]. An array of objects - a list of records - is the shape almost every REST API returns for a collection.How do I convert a JSON array of objects to CSV?
jq -r ".[] | @csv", in Python it is csv.DictWriter, and in the browser it is the converter above.How many rows will my CSV have?
What if my JSON is one object, not an array?
isinstance(rows, dict) check. You get a header row and one data row.What if the objects have different keys?
Turn your array into a table
Free, instant, and private — your JSON never leaves this tab.