Data · 3 min read ·
JSON to CSV without losing a single field
Nested keys, optional fields and commas inside strings — how 4Dev flattens messy JSON into a spreadsheet-ready CSV.

Spreadsheets are flat; JSON isn't. Every JSON-to-CSV conversion has to decide what to do with nested objects, arrays and keys that only some records have. Here is exactly what the 4Dev converter does.
Every key gets a column
The header row is built from the keys of every object, in the order they first appear — not just from the first record. A record that is missing a key gets an empty cell, so columns never shift and optional fields never disappear.
[{"id":1,"name":"Ada"},
{"id":2,"name":"Alan","note":"optional"}]
id,name,note
1,Ada,
2,Alan,optional
Nested objects become underscore columns
Objects are flattened by joining their keys with an underscore, so {"address":{"city":"Lisbon"}} becomes a column named address_city. An array of plain values goes into one cell ("admin, dev"), and an array of objects is kept as JSON text in its cell, so nothing is thrown away.
Commas and quotes are escaped for you
Any value that contains a comma, a double quote or a line break is wrapped in double quotes, and inner quotes are doubled — the standard CSV rule that Excel and Google Sheets expect.
2,"Alan, T.","says ""hi"""
Opening the CSV in Excel
CSV has no settings of its own, so Excel guesses. Two things often go wrong. In countries that use a comma as the decimal separator, Excel expects semicolons between columns and may put a whole row into one cell. And accented letters, Hebrew or emoji can turn into strange symbols when the file is opened as a local encoding instead of UTF-8. In both cases, use Data → From Text/CSV in Excel, choose UTF-8 and the comma delimiter, and the columns come out right.
Leading zeros and long numbers
Spreadsheets treat anything that looks like a number as a number. A ZIP code like 01234 loses its leading zero, and a 16-digit ID such as 1234567890123456 is rounded and shown as 1.23457E+15. The CSV itself is correct; the damage happens when Excel opens it. Import those columns as text, and send long IDs as strings in the JSON ("id": "1234567890123456"), so every tool keeps them exactly as they are.
Arrays inside records
Arrays are the hardest part of any conversion, because one record can hold many values while a CSV row has one cell per column. Spreading them over several rows would repeat every other field, and spreading them over numbered columns (tags_1, tags_2…) creates a different header for every file. Keeping a list of plain values in one cell, and an array of objects as JSON text, means every record stays exactly one row and the original data can be rebuilt if you need it.
Check the result before you share it
- The number of rows matches the number of records in the JSON array.
- The header contains every field you expect, including optional ones.
- Nested fields appear as underscore columns, such as address_city.
- Values with commas, quotes or line breaks stayed in one cell.
Need a spreadsheet or the reverse direction?
The 4Dev JSON to CSV converter runs the same flattening rules every time, and the related JSON to Excel and CSV to JSON tools cover the other common cases. For a quick check, paste a few records first, look at the columns, then convert the full file.