About the JSON to CSV
Convert JSON to CSV so you can open API responses, exports and database dumps in Excel, Google Sheets or any tool that reads spreadsheets. Paste an array of JSON objects: each object becomes a row and each key a column. The CSV appears next to it as you type, ready to copy or download as a .csv file.
The converter is meant for the flat, list-shaped data most APIs return, such as users, orders or products. The objects don't need identical keys. Every key found anywhere in the array gets a column, and rows that lack it are left blank.
How it works
The text is read with the browser's standard JSON parser. If it's an array, each element is one row; if it's a single object, it is treated as an array of one, giving a header and one row. The header row is the list of all keys in the order they first appear, scanning the objects from top to bottom.
Every cell, header included, is wrapped in double quotes, and any double quote inside a value is doubled, which is the escaping rule spreadsheets expect. Because of the quoting, commas and line breaks inside a value stay inside that cell. Nested objects and arrays aren't spread across extra columns; they are written into one cell as compact JSON text, so nothing is lost.
Assumptions and limits
- The input must be valid JSON: double-quoted keys, no trailing commas, no comments. If it isn't, the input box turns red and a message under it gives the line and column of the problem and the likely cause; no CSV is produced until it is fixed.
- The array must contain objects. An array of plain values such as [1, 2, 3] produces no CSV and a message saying so, because there are no keys to make columns from.
- A key that is missing from an object gives an empty cell. A key whose value is null gives the text null, and true or false are written as text too.
- Columns follow the order keys are first met, with one JavaScript quirk: within an object, keys that are whole numbers such as "2024" come before the others, in numeric order.
- Columns are separated by commas only. Whole numbers above 9,007,199,254,740,991 lose precision when JSON is parsed, so long IDs are safer stored as strings.
- The download is a UTF-8 file named data.csv, with rows ending in a plain line feed. It starts with a byte-order mark so Excel recognises the encoding; Copy CSV copies the text without it.
Worked examples
An API list of users
Two objects with the same keys become a header and two rows. Every cell, the header included, is wrapped in double quotes, and numbers are written the same way as text.
[{"id": 1, "name": "Ayesha", "city": "Lahore"},
{"id": 2, "name": "Omar", "city": "Dubai"}]
"id","name","city"
"1","Ayesha","Lahore"
"2","Omar","Dubai"Objects with different keys
The second order has a coupon field the first one lacks. The column is added and the first row's cell is left empty, so every row still lines up under the header.
[{"order": 101, "total": 25.5},
{"order": 102, "total": 40, "coupon": "SAVE10"}]
"order","total","coupon"
"101","25.5",""
"102","40","SAVE10"A nested address
A value that is itself an object stays together in one cell as JSON text, with its inner quotes doubled for CSV.
{"name": "Sara", "address": {"city": "Karachi", "zip": "74000"}}
"name","address"
"Sara","{""city"":""Karachi"",""zip"":""74000""}"How each JSON value is written to CSV
This converter goes one way only; the CSV to JSON converter handles the reverse direction.
| JSON value | CSV cell | What happens |
|---|---|---|
| "Lahore" | "Lahore" | text is kept as it is |
| 25.5 | "25.5" | numbers are written as quoted text |
| 1.50 | "1.5" | trailing zeros are lost when the JSON is read |
| true | "true" | true and false become words |
| null | "null" | the word null, not an empty cell |
| (key missing) | "" | an empty cell |
| "Shop, Ltd" | "Shop, Ltd" | the comma stays inside the cell |
| "6\" pipe" | "6"" pipe" | an inner quote is doubled |
| ["red","blue"] | "[""red"",""blue""]" | an array becomes JSON text |
How to use the JSON to CSV
- Paste the JSON. Replace the three-person sample in the left box with your array of objects; the bin icon clears it.
- Check the CSV output. The right box shows the CSV and a row count; if the JSON isn't valid, the message under the input says where and why.
- Copy or download. Use Copy CSV for the clipboard or Download .csv to save data.csv for Excel or Google Sheets.
Frequently asked questions
How do I open the converted file in Excel?
Download data.csv and double-click it, or in Excel choose Data, From Text/CSV and pick the file. The file is marked as UTF-8, so accented letters and non-English text open correctly. If you paste copied CSV into an older Excel instead and the text looks garbled, use the From Text/CSV import with the file origin set to UTF-8.
Can I convert nested JSON to CSV?
Yes, but nested objects and arrays are not flattened into separate columns. Each one is written into a single cell as JSON text, for example a tags array appears as ["red","blue"]. Flatten the data first if you need every nested field in its own column.
Why is every value wrapped in quotes?
Because a fully quoted cell is always valid CSV, and commas, quotes or line breaks inside your data can then never split a cell by mistake. Excel, Google Sheets and CSV libraries remove the quotes when they read the file.
Does the JSON have to be an array?
No. A single object works too and gives a header row plus one data row. What doesn't work is an array of plain numbers or strings, because there are no keys to turn into column names.
My JSON from an API won't convert. What's wrong?
Read the message under the input: it gives the line and column where the JSON breaks and the likely cause. The usual causes are single quotes instead of double quotes, a trailing comma after the last item, or copying only part of the response. If the list is inside a wrapper such as {"data": [...]}, paste just the array.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.