How to convert JSON to CSV, and CSV back to JSON, without losing data
The short answer. Paste a JSON array of objects into a converter: each object becomes a row and each key becomes a column. Nested objects are flattened into dot-named columns such as address.city, and arrays are written into one cell as JSON text. Going back, each CSV row becomes an object, with the first row giving the key names.
JSON and CSV hold data in different shapes. CSV is a flat grid: rows and columns, nothing inside anything else. JSON is a tree: an object can contain another object, or a list of them. Converting between the two is easy when the JSON is already flat, and every problem people hit comes from the parts that are not.
What a converter does to each kind of value
| In the JSON | In the CSV | Comes back as |
|---|---|---|
"name": "Asha" |
a name column |
the same string |
"id": 42, "active": true |
42, true |
a number and a boolean, if the converter infers types |
"address": {"city": "Pune"} |
an address.city column |
a flat key named address.city, not a nested object |
"tags": ["new", "vip"] |
one cell holding ["new","vip"] |
the text ["new","vip"], unless you parse it again |
| a key missing from some objects | an empty cell in those rows | null or an empty string |
"pin": "007" |
007 |
"007" only if the converter keeps leading zeros as text |
The last two rows of that table are where data quietly goes wrong. A good converter tells you when it flattened something or put an array into a cell, so you know the trip is not lossless.
How to convert JSON to CSV
- Check the JSON is valid first. A trailing comma or a single quote stops every converter; JSON Formatter points at the exact line.
- Make sure the top level is an array of objects, one object per row:
[{...}, {...}]. If an API wraps the list, as in{"data": [...]}, copy out just the array. - Open JSON to CSV and paste the array, or open the
.jsonfile. - Read the warnings. They list which keys were flattened into dot-named columns and how many arrays were written into single cells.
- Check the table preview: one row per object, one column per key, no column you did not expect.
- Copy the CSV or download it, then open it in a spreadsheet (see the Excel section below before you do).
A worked example
This JSON has a nested address, an array of tags, and a second record with no pin:
[
{"id": 1, "name": "Asha", "address": {"city": "Pune", "pin": "411001"}, "tags": ["new", "vip"]},
{"id": 2, "name": "Ravi", "address": {"city": "Delhi"}}
]
It converts to:
id,name,address.city,address.pin,tags
1,Asha,Pune,411001,"[""new"",""vip""]"
2,Ravi,Delhi,,
Three things happened. The address became two columns, address.city and address.pin. The tags array became one cell, wrapped in quotes with its own quotes doubled, which is how the CSV standard (RFC 4180) escapes a quote inside a field. And Ravi's missing pin and missing tags became empty cells, so the columns still line up.
How to convert CSV back to JSON
- Open CSV to JSON and paste the data or open the file. The separator (comma, semicolon, tab or pipe) is detected from the data.
- Leave first row as headers on if the first line holds column names; those become the keys.
- Check the types. Numbers,
true/falseand empty cells become numbers, booleans andnull, but values like007or a 19-digit account number stay as text so nothing is changed. - Copy the JSON array.
Dot-named columns come back as flat keys: address.city stays a key called address.city, it is not rebuilt into an address object. If your code needs the nested shape, rebuild it in code after parsing, or keep the original JSON as the master copy.
Why Excel breaks the numbers
Most damage happens after the conversion, when the CSV is opened in Excel by double-clicking it. Excel guesses each column's type, and two of its limits bite:
- Leading zeros vanish. A PIN code
007or a phone number09876543210is read as a number and shown as7or9876543210. - Long numbers are rounded. Excel keeps 15 significant digits. A 16-digit card number or a 19-digit ID keeps its first 15 digits and the rest become zeros, and saving the file writes the damaged value back.
To avoid both, import instead of double-clicking: in Excel use Data → From Text/CSV, and set those columns to Text before loading. Excel also stops at 1,048,576 rows per sheet, so a larger export has to be split or opened in a database.
When CSV is the wrong format
CSV suits data that really is a table. If most of your JSON is nested lists, such as orders that each contain items that each contain options, flattening produces either hundreds of columns or cells full of JSON text, and neither is pleasant to work with. Two better routes:
- One table per level. Export orders to one CSV and items to another, with an
order_idcolumn linking them. That is how a database would store it. - Keep it as JSON, or use YAML if people need to read and edit it. JSON to YAML keeps the nesting intact.
If it doesn't work
- "Unexpected token" or "invalid JSON". The input is not valid JSON. Common causes: single quotes instead of double, a trailing comma after the last item, or a log line pasted with the JSON. Run it through JSON Validator to see the line.
- "This JSON is a single value". CSV needs rows. Wrap a single object in
[ ], or pick out the array inside the wrapper object. - Everything is in one column in Excel. Your region uses a semicolon as the list separator. Import with Data → From Text/CSV and choose Comma, or convert with a semicolon separator.
- Hindi or accented text shows as garbage. The file is UTF-8 and Excel opened it as another encoding. Import it with Data → From Text/CSV and choose 65001: Unicode (UTF-8).
- Some columns are missing. A key that appears in no object never becomes a column. If some objects use
Nameand othersname, they are different keys and become two columns.
Questions people ask
How do I convert nested JSON to CSV?
Nested objects are flattened into columns whose names join the keys with a dot, so {"address": {"city": "Pune"}} becomes a column called address.city. Arrays cannot be spread across columns safely, so most converters write them into a single cell as JSON text. For deeply nested data, export each level to its own CSV linked by an ID column.
Can I convert JSON to CSV for Excel?
Yes. Convert the JSON to CSV, then open it in Excel through Data → From Text/CSV rather than by double-clicking the file. The import lets you set ID, phone and PIN columns to Text, which stops Excel from dropping leading zeros and rounding numbers longer than 15 digits. Excel holds at most 1,048,576 rows on a sheet.
Why did my CSV lose the leading zeros?
Excel opened the file and treated values like 007 or 09876543210 as numbers, which have no leading zeros. The CSV itself is usually fine; open it in a text editor to check. Re-import with Data → From Text/CSV and set those columns to Text, and avoid saving over the CSV from Excel until you have.
Does converting CSV back to JSON restore the nesting?
Not on its own. A column named address.city comes back as a flat key with a dot in its name, not as an address object with a city inside it. Cells holding JSON text, such as ["new","vip"], come back as strings. Rebuild the nesting in code if you need it, or keep the original JSON as the master copy.
Is it safe to paste customer data into an online converter?
Only if the converter runs in your browser. Many sites upload what you paste to their server. The JSON to CSV converter here does the work inside the page on your device, so the data is not sent anywhere, and it keeps working with the network switched off after the page has loaded.
Sources
Checked 5 Oct 2026:
- RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format (objects, arrays, strings and numbers)
- RFC 4180, Common Format and MIME Type for Comma-Separated Values (CSV) Files (section 2: quoting fields and doubling quotes inside them)
- Microsoft: Excel specifications and limits (15-digit number precision, 1,048,576 rows)
- Microsoft: Import or export text (.txt or .csv) files (Data → From Text/CSV, column types, file origin)