About JSON to CSV
You have a JSON response from an API and someone wants it in Excel. The awkward parts are the nesting, the fields that only appear on some records, and the outer object wrapped around the list. This page deals with those three things and gives you a CSV with one row per record.
Analysts, support staff and developers all run into this when a report has to leave a system that only speaks JSON. It also reads JSON Lines, the one-object-per-line format that many logging and data export tools write.
The result is a CSV to copy or download, with a table preview to check before you send it to anyone.
How it works
If the top level is an object holding exactly one list of objects, such as {"data": [...]}, that list becomes the rows and you get a notice saying what was left out. When there are several such lists, the whole object becomes one row, and the notice asks you to paste only the list you want.
Columns are the union of the keys across every record, in the order they first appear, so a field that only shows up on row 900 still gets a column. With flattening on, {"customer": {"name": "Ada"}} becomes a customer.name column. Lists stay whole and go into a single cell as JSON text, because spreading them out would create a different number of columns for each record.
Cells are quoted only when they contain the delimiter, a quote or a line break, and inner quotes are doubled as RFC 4180 specifies. An ID longer than 15 or so digits, which would normally be rounded on its way through JavaScript, is kept as text with every digit.
How to use JSON to CSV
- Paste the response into the JSON box, or use Open file for
.jsonor.jsonl. - Look over the Table preview, and read any notice about what was unwrapped.
- Under Options, choose a semicolon delimiter if your Excel locale expects one.
- Finish with Copy or Download .csv.
An API response with nesting and uneven fields
{"page":1,"data":[{"id":101,"customer":{"name":"Ada"},"items":["pen","ink"]},{"id":102,"customer":{"name":"Grace"},"note":"Gift, wrap it"}]}id,customer.name,items,note
101,Ada,"[""pen"",""ink""]",
102,Grace,,"Gift, wrap it"The page field was left out with a notice, customer.name became a column, the items list stayed in one cell as JSON, and note exists only on the second record, so the first row has an empty cell.
When it helps
- Giving a colleague an API result they can sort and filter in a spreadsheet.
- Exporting records from a document database for a one-off report.
- Reviewing application logs written as JSON Lines by filtering on a column.
- Comparing two API responses by putting each into a sheet.
Tips for a better result
- Turn on the byte order mark option if the file will open in an older version of Excel and has accented characters. Without it, Excel may guess the wrong encoding.
- If a nested list matters to you, flatten it first with the JSON Flattener, so that each position gets its own key.
- In Excel, a long ID shown in scientific notation is a display issue on opening. Import the file as text to keep the digits visible.
Good to know
- Lists inside a record are not expanded into extra rows. Each record is exactly one row.
- A list mixing objects with plain values is refused, with the position of the first odd item, since it has no sensible columns.
- A key that contains a dot can collide with a flattened path. When that happens the later value wins and a notice names the column.
- Cells that begin with
=are written as they are, so treat a CSV from an untrusted source with care when opening it in a spreadsheet.
Questions people ask
Why did my nested data end up in one column?
Flattening handles objects but keeps lists whole. A field like items: ["pen", "ink"] stays as JSON text in a single cell, because each record could have a different number of items and the columns would no longer line up.
Does it work with a JSON Lines file?
Yes. If the input is not one JSON document but every non-empty line is valid JSON on its own, each line becomes a row, and a notice confirms that this is how it was read.
Which columns do I get if records have different fields?
All of them. The header is built from every record rather than the first, and a record without a given field gets an empty cell there.
Can I convert a plain list such as [1, 2, 3]?
A list of plain values becomes a single column called value. A list of lists is treated as rows, with the first inner list used as the header.
What to use next
- JSON Validator: if the JSON fails to parse and you want a closer look
- CSV to JSON: to go back the other way
- JSON Flattener: when you want list items spread into separate keys
Learn more
Last reviewed . Read our editorial policy.