Convert JSON to CSV
Flatten JSON or JSON Lines into a CSV table, nested fields included.
- Nothing is uploaded
- Free
- No sign-up
Guide
JSON to CSV: the complete guide
Last updated 3 min read
About this tool
PrivateCSV converts a JSON array, or a JSON Lines file, into CSV with one row per object and one column per field. Nested objects are flattened into columns such as address.city, records wrapped in an object like {"data": [...]} are found automatically, and fields missing from some objects are left empty. Your JSON is converted in your browser and is not sent anywhere.
How to convert JSON to CSV
- Choose a .json or .jsonl file.
- Keep “Excel-compatible” ticked if you will open the CSV in Excel; untick it for a database or script.
- Click Convert to CSV. The result shows how many rows and columns were created and where the records were found.
- Download the CSV and open it in Excel, Google Sheets or your database tool.
Example
Nested objects become dot columns, simple arrays are joined.
{
"data": [
{ "id": 1, "name": "Ana", "address": { "city": "Lisbon" }, "tags": ["admin", "beta"] },
{ "id": 2, "name": "Ben", "active": true }
]
}id,name,address.city,tags,active
1,Ana,Lisbon,admin; beta,
2,Ben,,,trueWhen you need it
- API responses in a spreadsheet
- Most APIs answer in JSON. Save a response to a file and convert it to inspect the data, share it with someone who works in Excel, or attach it to a report.
- Database and app exports
- mongoexport writes one JSON document per line by default, and many apps export JSON. CSV is what spreadsheets, BI tools and most import wizards expect.
- Logs and event data
- Structured logs are often JSON Lines, one event per line. As CSV they can be sorted, filtered and counted in any spreadsheet.
How nested JSON is flattened
- Nested objects become dot-separated columns: {"address": {"city": "Lisbon"}} gives a column address.city.
- Arrays of simple values are joined in one cell: ["admin", "beta"] becomes admin; beta.
- Arrays of objects, such as order line items, are kept as JSON text in one cell, so nothing is lost.
- The columns are every field found in any record, in the order they first appear. A missing field or a null value leaves an empty cell.
- Numbers and true/false are written exactly as they appear in the JSON.
Where the records are found
If the file is an array, each element becomes a row. If it is an object, the first property that holds a non-empty array is used, which covers common API shapes such as {"data": [...]}, {"results": [...]} and {"items": [...]}. A single object becomes a single row. A file that is not one JSON document is read as JSON Lines, one value per line.
Limits to know about
- The whole file is loaded before converting, because a JSON document can only be read once it is complete. Very large files can exceed the memory of a browser tab, especially on phones.
- Arrays of objects are kept as JSON text in one cell; they are not expanded into extra rows.
- When records are wrapped in an object, only the first array is used.
- The CSV is UTF-8. “Excel-compatible” (on by default) adds a byte order mark so Excel displays accented letters correctly when you double-click the file. Untick it for databases and scripts that read the mark as part of the first column name.
Frequently asked questions
How do I convert a JSON file to CSV?
Choose the file and click Convert to CSV. Each object becomes a row and each key a column; keys missing from some objects leave empty cells.
How are nested objects and arrays handled?
Nested objects become columns with dot paths, such as address.city. Arrays of simple values are joined with “; ” in one cell, and arrays of objects are kept as JSON text in one cell.
Can I convert JSON Lines (NDJSON)?
Yes. If the file is not a single JSON document, it is read as JSON Lines, with one JSON object per line.
Should I convert JSON to CSV or to Excel?
Choose CSV when the file goes into another system, such as a database, an import wizard or a script; CSV has no row limit. Choose Excel (.xlsx) when a person will open it: numbers stay numbers, accented characters display correctly and nothing depends on regional settings, but a sheet stops at 1,048,576 rows.
How do I convert JSON to CSV in JavaScript?
With the PapaParse library, Papa.unparse(records) turns an array of flat objects into CSV text, in the browser or in Node.js. Flatten nested objects first: unparse writes them as [object Object] and joins arrays with commas inside one quoted cell.
How do I convert JSON to CSV in Python?
With pandas: pd.json_normalize(data).to_csv("out.csv", index=False). json_normalize flattens nested objects with dots, the same convention this tool uses.
Related tools
Go further
Your files never leave your device
PrivateCSV runs every tool inside your browser. No upload, no account, nothing to install.