JSON is built out of boxes inside boxes. A customer record holds an address object, the address holds a city, and an order history holds a list of further objects. CSV has none of that: it is a flat grid of rows and cells, and a cell can hold one plain value and nothing else. So when you convert JSON to CSV, the nesting has to go somewhere.
This guide explains where it goes when you use the free JSON to CSV Converter on Ovatly. Nested objects flatten into dotted columns, arrays take one of two paths, and a union rule decides the columns.
Contents
- Quick answer
- A table has no inside
- Nested objects flatten into dot-style columns
- Arrays take one of two paths
- The union rule decides the columns
- How to convert, step by step
- Worked example: two customers, one nested address
- The depth warning: nesting makes tables wide
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
When you convert JSON to CSV with the JSON to CSV Converter, nested objects flatten into dot-style columns, so an address object produces a column called address.city. Simple arrays join into one cell with "; ", while arrays of objects are written as JSON text inside the cell. The columns are the union of every key in every record, in first-appearance order, and a key a record does not have leaves an empty cell. Values are written exactly as they appear, never reformatted, and the conversion runs locally in your browser.
A table has no inside
The mismatch is structural. JSON describes a tree: objects inside objects, as deep as the data needs. CSV describes a rectangle: a header row of column names, then one row per record, each intersection holding a single value.
A converter cannot preserve nesting as nesting. It has to project the tree onto the rectangle, and every choice it makes is visible in the output if you know what to look for. The three choices that matter are how objects flatten, how arrays are squeezed into cells, and which columns exist at all.
Nested objects flatten into dot-style columns
When a record holds an object as a value, the converter walks into it and gives each leaf value a column named by its path joined with dots: the city inside the address becomes address.city.
Flattening keeps every value individually addressable, which is what a spreadsheet or database needs: a filter on address.city works because the city is a real column with one plain value per row. The cost is width: each nested field adds a column, and the header row becomes a map of the original tree's shape. Records that share a path share the column, which is what makes the rows line up.
Arrays take one of two paths
Arrays cannot flatten the same way: an array is a list of values under one key, not a set of named fields. What happens depends on what the array holds.
A simple array of plain values, such as a list of tags, joins into a single cell with "; " as the separator, surviving as readable text you can split again later.
An array of objects is different: each item has its own fields, so there is no honest single-cell summary, and the converter writes the array as JSON text inside the cell instead. The data is preserved whole, and because that text contains commas, the CSV wraps the cell in quotes like any other field that contains a comma. You can read or parse it back downstream, but it will not behave like separate columns.
The union rule decides the columns
Real data is untidy: not every record carries every key. The converter takes the union of all keys across all records, in first-appearance order, so a key that shows up only in the ninth record still becomes a column.
The consequence is empty cells. A record that never had that key leaves the cell blank, and that blank is information, not damage: it says the value was missing in the source. The table is rectangular, so every record must have a cell for every column.
How to convert, step by step
- Open the JSON to CSV Converter and paste your JSON, or upload a .json file.
- Check the shape before converting: an array of objects gives one row per object, a single object gives a one-row table, and an array of arrays is accepted as rows directly.
- Convert, then read the record and column counts the tool shows: they are your first sanity check.
- Download converted.csv and scan the header row and a few rows before relying on it.
Worked example: two customers, one nested address
Take two customers: Ana in Lisbon, and Ben in Porto, who also has an age:
[
{ "name": "Ana", "address": { "city": "Lisbon" } },
{ "name": "Ben", "address": { "city": "Porto" }, "age": 31 }
]
The address flattens into address.city. Age appears only in Ben's record, but the union rule still makes it a column, so Ana leaves it empty:
name,address.city,age
Ana,Lisbon,
Ben,Porto,31
Two records, three columns, one empty cell: nothing was lost, Ana simply has no age in the source. Now add a list to her record:
{ "name": "Ana", "tags": ["new", "vip"] }
The tags cell in her row reads new; vip. Had the list held objects instead, the cell would carry the list as JSON text, preserved but not flattened.
The depth warning: nesting makes tables wide
Flattening is faithful, and faithfulness has a price. Each level of nesting lengthens the column names, and each leaf adds a column. One level, like address.city, is easy to read; three levels produce a header row that sprawls, with most cells empty because few records populate every branch.
If your output looks like that, a single flat table may not be the data's best home. Converting one array at a time often gives smaller, more usable tables.
Limitations and honest tradeoffs
Flattening is a projection, and projections lose shape. From the CSV alone you cannot always tell whether address.city was a nested field or a key that literally contained a dot. Arrays of objects survive only as text, so their inner fields cannot be filtered or summed until something parses them back. Scalars and mixed arrays are rejected with an explanation rather than converted, because a list of plain numbers has no clear columns. Values are never reformatted, so dates and numbers arrive exactly as written, in whatever form the source used.
Common mistakes
- Expecting the nested object to stay together. It becomes separate dot-style columns. Look for address.city, not an address column.
- Reading an empty cell as a conversion error. It means the record had no value for that key.
- Hunting for lost columns. A late-appearing key still becomes a column, in first-appearance order, not alphabetical order.
- Trying to filter an array of objects inside its cell. It is JSON text there; parse it back, or convert that array separately.
- Feeding a list of numbers and expecting a table. Plain scalars and mixed arrays are rejected, by design.
FAQs
How are nested objects shown in the CSV? They are flattened into dot-style columns. A field such as address holding a city becomes the column address.city, one column per leaf value, so every cell holds a single plain value.
What happens to an array inside a record? A simple array of plain values is joined into one cell with '; ' as the separator. An array of objects cannot be flattened that way, so it is written as JSON text inside the cell, where it can be read or parsed later.
Why does my CSV have columns that are empty for most rows? The columns are the union of all keys found in any record. If only one record carries a key, that key still becomes a column, and every other record leaves that cell empty. An empty cell means the value was missing, not that the conversion failed.
Can I convert a single JSON object instead of an array? Yes. A single object becomes a one-row table with its keys as the header row, and nested objects inside it flatten in the same dot style.
Does the converter change my values? No. Values are written exactly as they appear in the JSON, never reformatted. Numbers, dates and text keep their original form, and any retyping is a job for the spreadsheet or database that receives the file.
Conclusion
Nesting does not disappear in a conversion; it changes form. Objects become dot-style columns, simple arrays become joined text, arrays of objects stay as JSON inside a cell, and the union of keys decides the columns. Once you know those four rules, the output of the JSON to CSV Converter stops being surprising. If your next step is a database, our guide on converting JSON to CSV for importing into a database covers the import side, and the Data and JSON Tools guides cover the rest of this series.
References
- RFC 4180, the common CSV format and its quoting rules: https://www.rfc-editor.org/rfc/rfc4180
- MDN Web Docs, on JSON structure, objects and arrays: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON