An API hands you a JSON array. Your spreadsheet wants rows and columns. Between the two sits a set of quiet decisions: which fields become columns, in what order, what happens to an object nested inside a record, and what lands in the cell when one record simply does not have a value that another one does.
This guide is built around one worked example. We take a small array of objects, run it through the free JSON to CSV Converter on Ovatly, and read the output line by line, so every one of those decisions is visible instead of guessed at.
Contents
- Quick answer
- The shape the converter expects
- Where the columns come from
- How to convert, step by step
- Worked example: two records, read line by line
- Second pass: a simple array inside a record
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Paste a JSON array of objects into the JSON to CSV Converter and it returns a comma-delimited CSV file, converted.csv, with one row per record. The header row is the union of all keys in the array, in the order they first appear. Nested objects are flattened into dot-style columns such as address.city, and any value a record is missing stays empty in its cell. The tool shows the record and column counts before you download, and everything runs locally in your browser: nothing is uploaded, and the tool never fetches data from anywhere.
The shape the converter expects
The converter is built for tabular data wearing JSON clothes: an array where each element is an object, and each object is one row. The keys of the objects become the columns. If your JSON is a single object rather than an array, it still converts, as a one-row table. An array of arrays is accepted too, and treated as rows directly.
Two shapes are refused, with an explanation rather than a silent failure. A bare scalar, such as a number or a string on its own, has no keys and therefore no columns. A mixed array, where some elements are objects and others are not, has no consistent column set either. In both cases the data needs reshaping before it can be a table, and the tool tells you so instead of producing a broken file.
Where the columns come from
Real records rarely agree with each other. One has an age, the next does not. One carries an extra field the others never heard of. The converter handles this with a union rule: collect every key from every record, keep them in the order they first appear, and give each key a column. A record that lacks a key is not an error. It simply leaves that cell empty.
Nested objects get the same treatment, one level of naming deeper. An address object inside a record does not become a blob of JSON in a cell. Its inner keys are flattened into dot-style column names, so address.city sits alongside name as an ordinary column.
How to convert, step by step
- Open the JSON to CSV Converter and paste your JSON array, or upload a .json file.
- Check the record and column counts the tool shows. They are your first sanity check: the record count should match the number of objects in your array.
- Download converted.csv and open it in your spreadsheet. Read the header row and a data row or two before you trust the whole file.
Worked example: two records, read line by line
Here is the input. Two records: Ana, who lives in Lisbon and has no age recorded, and Ben, who lives in Porto and is 31. Each carries an address object with a single city inside it.
[
{ "name": "Ana", "address": { "city": "Lisbon" } },
{ "name": "Ben", "address": { "city": "Porto" }, "age": 31 }
]
And here is the CSV that comes out:
name,address.city,age
Ana,Lisbon,
Ben,Porto,31
Read the header row first: name,address.city,age. Those are the union of all keys, in first-appearance order. Reading the input top to bottom, name appears first. The address object contributes address.city, flattened from the nested object. Age appears last because it only shows up in the second record, and the union rule still gives it a column.
Now Ana's row: Ana,Lisbon, and then nothing. The trailing comma with an empty cell after it is the age column being honestly empty. Ana has no age in the source, so the cell stays blank rather than being filled in with a zero, and the row keeps the same three-column shape as every other row.
Ben's row, Ben,Porto,31, is complete: name, the flattened city, and the age, written as it appears in the JSON. Values are never reformatted, so the 31 you read in the spreadsheet is the 31 that was in the source.
Second pass: a simple array inside a record
One more shape worth seeing before it surprises you: a record with a list inside it:
[
{ "name": "Ana", "address": { "city": "Lisbon" }, "tags": ["new", "vip"] }
]
A simple array cannot be flattened into dot columns, so its values are joined into a single cell with "; " between them. The output reads:
name,address.city,tags
Ana,Lisbon,new; vip
One cell holds both tags, readable at a glance. The exception to remember: if the array contains objects rather than plain values, the cell holds the JSON text of that array instead, because there is no single plain value to write. Our companion guide on exporting API data to CSV for a client report covers the reporting workflow built on top of this same conversion.
Limitations and honest tradeoffs
Flattening is a convenience with a cost. A deeply nested record produces a wide table with many dot-style columns, and the structure of the original nesting is flattened away. If you need the nesting preserved, CSV is the wrong destination format.
Standard minimal quoting is used, so a value containing a comma or a quote is wrapped in double quotes in the output. That is correct CSV and spreadsheets read it properly, but if you open the raw file in a text editor, expect to see those quotes; they are not corruption.
Finally, the empty-cell rule cuts both ways. A blank means the record had no value. It does not distinguish between a field that was absent and one that was present but empty in the source, so if that distinction matters to your analysis, check the JSON before converting.
Common mistakes
- Expecting the first record to define the columns. It does not. The union of all keys does, so a field that appears only in the last record still gets a column, and earlier rows show blanks there.
- Reading an empty cell as a zero or an error. It means the record had no value for that key. The conversion succeeded; the data was simply incomplete.
- Feeding the tool a mixed array. Objects mixed with scalars are rejected with an explanation. Reshape the data so every element is an object first.
- Assuming a nested object stays nested. It flattens into dot-style columns. If a cell surprises you with JSON text, the value was an array of objects, which is the one shape written as JSON.
- Editing values in the CSV and expecting the JSON to match. The output is a one-way snapshot. Change the source JSON and convert again.
FAQs
What JSON input does the converter accept? An array of objects is the main case. A single object becomes a one-row table, and an array of arrays is also accepted. Scalars and mixed arrays are rejected with an explanation, because they have no consistent set of columns.
Why is there a column that only one record uses? The columns are the union of all keys across every record, in first-appearance order. If one record has a key the others lack, that key still gets a column, and the records without it get an empty cell in that column.
What happens to a nested object inside a record? It is flattened into dot-style columns. An address object with a city inside it becomes a column named address.city, so the nested value sits in the same flat row as everything else.
How are arrays inside a record handled? A simple array, such as a list of tags, is joined into one cell with '; ' between the values. An array of objects is written as JSON text inside the cell, because it cannot be flattened into a single plain value.
Is my data uploaded, and are values changed? No upload happens: the conversion runs locally in your browser. Values are written as they appear in the JSON and are never reformatted, so what you read in the CSV is what was in the source.
Conclusion
Converting an array of objects to spreadsheet rows is deterministic once you know the rules: union of keys for the columns, first-appearance order, dot-style flattening for nested objects, and an empty cell wherever a record has no value. The JSON to CSV Converter applies those rules in your browser and shows you the counts before you download. For more guides in this series, see our Data and JSON Tools guides.
References
- RFC 4180, the common format and MIME type for CSV files: https://www.rfc-editor.org/rfc/rfc4180
- MDN Web Docs, on the JSON format and working with it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON