Guide
How to Convert JSON to CSV
CSV is the format spreadsheets and data tools expect, so turning a JSON response into CSV is a common chore. It is straightforward when your JSON is a flat list of records and gets more involved when the data is nested. This guide covers both.
The ideal shape: an array of flat objects
CSV is a grid. The first row is usually a header of column names, and every row after that is one record. JSON maps to this cleanly when it is an array of objects that all share the same keys.
[
{ "id": 1, "name": "Ada", "active": true },
{ "id": 2, "name": "Linus", "active": false }
]That converts directly to:
id,name,active
1,Ada,true
2,Linus,falseEach object key becomes a column, and each object becomes a row. This is the case every JSON to CSV converter handles well.
The hard part: nested objects
Real API data is rarely flat. When a record contains a nested object, there is no obvious single cell to put it in. The common solution is to flatten nested keys into dotted column names.
[
{
"id": 1,
"name": "Ada",
"address": { "city": "Berlin", "zip": "10115" }
}
]Flattened, the address becomes two columns:
id,name,address.city,address.zip
1,Ada,Berlin,10115This keeps every value while staying flat. The column names get longer, but nothing is lost and the result still opens cleanly in a spreadsheet.
The harder part: arrays inside a record
An array inside a record has no clean flat representation, because one record now holds many values for a single field. There are two usual approaches, and which one is right depends on what you plan to do with the CSV.
- Join the array into one cell, for example "admin, editor", when you only need to read or eyeball the values.
- Expand into multiple rows, repeating the rest of the record for each array item, when you need to analyze or group by those values.
Joining keeps one row per record but makes the array cell harder to work with. Expanding is closer to how relational data works but multiplies your row count. Neither is wrong. Pick based on the destination.
Convert it
- Paste or import your JSON into the converter and choose CSV as the target.
- Confirm the top level is an array of objects. If your data is wrapped in an outer object, point the converter at the array inside it.
- Check how nested objects and arrays came out, since that is where representation choices happen.
- Copy or download the CSV.
Because the conversion runs in your browser, you can do this with exports and reports that you would not want to paste into a remote service.
Things to watch for
- Missing keys: if records do not all share the same keys, some cells will be empty. That is expected, not an error.
- Commas and quotes in values: a value that contains a comma has to be quoted in CSV so it does not split into two columns. A good converter handles this for you.
- Type changes: CSV has no types. Numbers, booleans, and null all become text, so a downstream tool may need to reinterpret them.
FAQ
What JSON shape converts to CSV most cleanly?
An array of objects that share the same keys. Each key becomes a column and each object becomes a row, with no representation decisions needed.
How are nested objects handled?
They are usually flattened into dotted column names, so address.city and address.zip become separate columns while keeping every value.
What happens to arrays inside a record?
They are either joined into a single cell or expanded into multiple rows. Joining is simpler to read, expanding is better for analysis. Check the output to see which fits.