Skip to tool
ecech.
💻 Developer & Code

JSON to CSV That Shows You What Flattening Costs Before You Accept It

Nested objects become dotted columns. Arrays have no right answer, so you get both options and what each one loses. Quoting is handled properly.

CSV



Columns found

Advertisement

How the calculation works

Two rows, different numbers of tags numbered columns tags.0, tags.1, tags.2 admin, dev, (empty) ops, (empty), (empty) widens with the longest row joined into one cell tags admin|dev ops stable shape, structure lost Neither is correct. Pick the one whose loss you can live with.

How to Use This Tool

Paste JSON and get CSV. The choices that matter are exposed rather than made silently, because they change what you can do with the result.

Nested objects become dotted columns

{"user": {"name": "Ada"}} becomes a column called user.name. This part is lossless and reversible — the dots record exactly where the value came from, so the structure can be rebuilt later if needed. Depth does not matter; a.b.c.d works the same way.

Arrays are the real decision

There is no lossless way to put a list in a flat cell, so you are choosing which problem to have:

  • Joined into one celladmin|dev. The table keeps a stable shape no matter how many items each row has. The cost is that the list becomes a string, so a spreadsheet cannot filter on one item without splitting it again. Pick a separator that cannot appear in your data.
  • Numbered columnstags.0, tags.1. Each item stays addressable. The cost is that the table widens to fit the longest row, most cells end up empty, and adding one item with more entries changes the header. Fine when array lengths are fixed and known; fragile otherwise.

Missing keys, and why the header is a union

Real API responses do not have identical keys in every object. The header here is the union of every key that appears anywhere, and a row that lacks one gets an empty cell in that position.

The alternative — writing each row's own keys in order — produces a file where values land under the wrong headers, which is the most damaging CSV bug there is because it looks fine until someone reads the wrong column and believes it.

Where hand-rolled CSV writers break value contains a comma "London, UK" quote the whole field value contains a quote "says ""hi""" double the inner quote value contains a newline "line1↵line2" quote it; the row survives Miss any of these and the row silently splits into two, shifting every column after it.
Quoting is the unglamorous part that decides whether the file is readable at all.

The Excel option

The Excel-safe checkbox adds a byte order mark to the front of the file. Without it, Excel opens a UTF-8 CSV as if it were the local legacy encoding, and any non-English text arrives as mojibake. The mark is invisible in every other tool and costs three bytes, so leaving it on is usually right. Turn it off if the file is going to a parser that treats the mark as part of the first column name — some do.

What CSV cannot carry

Types. Everything in a CSV is text, so true, 1 and "1" all arrive identically and whatever reads the file guesses again. Leading zeros in identifiers are particularly prone to being eaten by spreadsheets. If types matter for what happens next, CSV is the wrong destination and JSON Lines or Parquet will serve better.

Advertisement

Frequently Asked Questions

How do I convert nested JSON to CSV?
Flatten nested objects into dotted column names, so {"user":{"name":"Ada"}} becomes a column called user.name. That part is lossless. Arrays are the hard case, because a list cannot fit in a flat cell without either joining it into a string or spreading it across numbered columns.
Should arrays become one cell or numbered columns?
It depends on what you need. Joining into one cell keeps the table a stable width regardless of how many items each row has, but the list becomes a string a spreadsheet cannot filter. Numbered columns keep each item addressable but widen the table to the longest row and leave most cells empty.
What happens when rows have different keys?
The header becomes the union of every key found anywhere, and rows missing a key get an empty cell. The alternative — writing each row's own keys in order — puts values under the wrong headers, which is the worst kind of CSV bug because the file looks correct.
Why does my CSV look wrong when opened in Excel?
Usually the encoding. Excel opens a UTF-8 CSV as the local legacy encoding unless the file starts with a byte order mark, so accented and non-Latin characters arrive garbled. The Excel-safe option adds that mark. It is invisible elsewhere, though a few strict parsers treat it as part of the first column name.
How are commas and quotes inside values handled?
A value containing the delimiter, a quote or a newline is wrapped in quotes, and any quote inside it is doubled. This is the standard CSV escaping rule, and skipping it is why hand-rolled writers produce files where one row silently splits into two and every column after it shifts.
Does CSV preserve data types?
No. Everything becomes text, so true, 1 and "1" are indistinguishable once written, and spreadsheets frequently strip leading zeros from identifiers. If types matter downstream, JSON Lines or Parquet preserve them and CSV does not.
Is my JSON uploaded anywhere?
No. It is parsed and converted in your browser and nothing is transmitted.

Related tools in Developer & Code

Browse all Developer & Code tools
The Mac mini the ecech. site is built on, beside a handwritten note reading ecech.com.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.