How to Convert JSON to CSV (Free, Online, or with Python)
To convert JSON to CSV, map each object to a row and each key to a column header. For a flat array, the JSON to CSV converter does this directly. Nested objects need an explicit decision: keep each one as JSON text in a cell, or flatten it into separate columns with code.
JSON is hierarchical; CSV is a flat grid. The whole job is turning one into the other without losing data. Here's how.
JSON vs CSV Structure
JSON nests data; CSV is rows and columns:
[
{ "id": 1, "name": "Ada", "city": "London" },
{ "id": 2, "name": "Alan", "city": "Bletchley" }
]
becomes:
id,name,city
1,Ada,London
2,Alan,Bletchley
Each object becomes a row; each key becomes a column. The conversion is clean when your JSON is a flat array of objects.
Method 1: Convert Online in One Click
Paste a JSON array of objects into JSON to CSV, then copy or download the result. The converter runs locally in your browser. It takes the union of keys across rows; missing keys become empty cells. Objects and arrays inside a row are serialized as JSON text in one cell. It does not flatten them into dotted columns. To inspect and sort the rows first, use JSON to Table.
If the converter errors, your JSON may be invalid — check it first with the JSON Validator.
Method 2: Flatten Nested JSON
Real-world JSON often nests objects:
{ "id": 1, "name": "Ada", "address": { "city": "London", "zip": "EC1" } }
Flatten nested keys with dot notation so they become columns:
id,name,address.city,address.zip
1,Ada,London,EC1
Arrays inside objects are trickier — you either join them into one cell ("admin; editor") or expand them into multiple rows. Decide based on how you'll use the CSV.
Method 3: Convert with Python (pandas)
For large or deeply nested files, Python gives you control over flattening:
import pandas as pd
import json
with open("data.json") as f:
data = json.load(f)
# Flattens nested JSON automatically
df = pd.json_normalize(data)
df.to_csv("output.csv", index=False)
json_normalize expands nested objects into dotted columns; pass record_path and meta to explode nested arrays.
If a value contains a comma, quote, or line break, a CSV writer must quote that field and double any quote inside it. The browser converter handles those delimiters; a CSV parser must also accept line breaks inside quoted cells. For Python output, to_csv handles CSV quoting for you.
Method 4: Open the CSV in Excel
Once you have the CSV, open it directly in Excel or Google Sheets. If you'd rather go straight to a spreadsheet, see How to Convert JSON to Excel.
Untrusted data warning: CSV cells beginning with formula characters such as = may be executed by spreadsheet software. Treat exported data from unknown sources as untrusted and review it before opening the CSV in Excel or Sheets. See OWASP's CSV injection guidance.
Troubleshooting Irregular Keys
If objects have different keys, DevDecode unions all keys into the header and leaves blanks where a record lacks a value. Validate and pretty-print messy input first with the JSON Formatter. If you convert the CSV back to JSON, cell values are read as strings: original number, boolean, null, and nested types are not restored automatically.
Frequently Asked Questions
How do I convert JSON to CSV?
Map each JSON object to a row and each key to a column. Use an online JSON-to-CSV converter, or pandas.json_normalize() in Python.
How do I convert JSON to CSV in Python?
Load the JSON, run pandas.json_normalize(data) to flatten it, then call df.to_csv("output.csv", index=False).
How do I handle nested JSON?
Flatten nested keys into dotted column names (address.city), and either join or explode inner arrays depending on your needs.
Can Excel open JSON directly? Not as a table. Convert JSON to CSV first (or use Excel's Power Query), then open the result.
How do I convert a JSON array to CSV? A flat array of objects converts directly — each object is a row, each key a column. Paste it into a JSON-to-CSV tool.
Related Reading
The key choice is whether nested values should stay in one cell or become separate columns. For data exchange, also account for CSV quoting and the fact that a CSV round trip does not preserve JSON types. RFC 4180 documents the common CSV field format.