Two formats, two models of the data
JSON has types: a string, a number, a boolean, null, an object, an array. CSV has none of that — every cell is text, rows are independent, and a column is only a convention that the same position in each row happens to mean the same thing. A conversion is a translation between those two models, and every interesting bug in a converted file is one of the model differences showing through.
The four differences that cause nearly all of the trouble: precision (numbers), nesting (objects and arrays), quoting (strings that contain the delimiter), and identity (what a row even is when the records have different keys).
The ID that arrives wrong
The classic silent failure: an order or user ID with 17–19 digits converts fine, the file opens fine, and the ID is wrong. Two independent mechanisms do this, and it is worth telling them apart because the fixes differ.
- The parse step. Any JSON parser built on IEEE-754 doubles — JavaScript's
JSON.parseamong them — cannot represent integers exactly above 2^53. Past that point the last digits are rounded during parsing, before any conversion happens. A converter that parses and re-serialises has already changed the value. - The spreadsheet step. Excel keeps 15 significant digits and reformats long numbers in scientific notation, so a 19-digit ID survives the file and dies in the display: the trailing digits are zeroed on import. The fix is to keep the column as text, which only works if the CSV quotes the value and the importer is told not to re-parse it.
If the IDs matter, the honest answer is that a text-based round trip through a spreadsheet is the wrong tool — treat them as strings end to end, or keep IDs out of the spreadsheet entirely. If you only need to spot-check the data, the JSON to CSV converter quotes string values exactly as they appear in the source document.
Nested objects have no seat in a spreadsheet
A spreadsheet row is flat: one value per column. A JSON record can nest an address inside a customer inside an order. The converter has to decide what that object becomes, and each choice has a failure mode:
- Flatten to dotted columns.
customer.address.citybecomes a column header. This is the most useful default for analysis, but the headers grow long, and two records with different nesting produce different column sets — the converter must union the columns and leave the missing cells empty rather than dropping data. - Serialise into one cell. The nested value becomes a JSON string inside a cell. Nothing is lost, but the cell is unreadable without another parse — you have deferred the problem, not solved it. Useful for arrays you will process later; useless for fields you want to filter on.
- Split into more rows. Each array element becomes a row, duplicating the parent record. Legitimate for long-format analysis, but every downstream count is now per-element, not per-record, and joins back to the original data need a key column that still exists.
There is no universally right choice — the question is what the spreadsheet is for. Filtering and pivoting want flattening; archival fidelity wants serialised cells; per-element analysis wants the long format.
The quoting rules a naive converter misses
RFC 4180, the de-facto CSV standard, is short, and almost every broken CSV violates one of its three rules. A value containing a comma, a double quote or a line break must be wrapped in double quotes, and an embedded quote is escaped by doubling it. Naive converters — usually a join(",") over stringified fields — do none of this, and the file still opens, which is what makes the damage easy to miss:
name,note
Ada,"said ""hello"", then left"
Grace,"line one
line two"In the correct file above, row one is two cells and row two's second cell legitimately contains a newline. Open the unquoted version of the same data and the row boundary has moved: every field after the embedded comma shifts one column, and the note's second line becomes a record of its own. Nothing errors — the data is just wrong, quietly.
The other quoting trap is invisible until the file is opened on another machine: Excel on Windows reads a UTF-8 file without a byte-order mark using the legacy code page, and every non-ASCII character — accented names, CJK text, currency symbols — turns into mojibake. Writing a BOM is the one pragmatic fix, standards notwithstanding.
A conversion checklist
- IDs stay text. Any identifier longer than 15 digits must survive as a string. If it did not, check whether it was already rounded at parse time — see the precision guide on what JSON.parse does above 2^53.
- Spot-check the row count. Rows in the CSV should equal elements in the array. More rows means an embedded newline was not quoted; fewer means a record was dropped.
- Union the columns. Real-world records rarely share a schema. The header should cover every key that appears in any record, with empty cells for the gaps — not silently dropped fields.
- Pick the delimiter on purpose. Commas everywhere except where the destination spreadsheet's locale expects semicolons or tabs.
- Decide null. JSON
null, a missing key and an empty string are three different things that CSV can only render as the same empty cell. Pick one convention and keep it stable across conversions.
To check your own document against this list, the JSON to CSV converter runs the conversion in your browser — paste the JSON, choose the delimiter and nesting options, and download the file. Nothing is uploaded, so real customer data is safe to run through it.