How to convert JSON to CSV
Updated · 3 min read
JSON is great for nested, flexible data, but spreadsheets, BI tools and many import screens only understand flat tables. This converter walks through every JSON object, turns nested properties into columns, collects every key that appears in any record, and writes a standards-compliant CSV file.
- Paste JSON or drop a
.jsonfile — an array of objects, an API response or a single object. - Keep Flatten nested JSON to columns enabled to turn nested objects into
parent.childcolumns. - Choose a comma or semicolon under CSV output.
- Copy the CSV or download it; the downloaded file opens correctly in Excel, accents included.
Example
JSON input
[
{ "id": 1, "name": "Jane", "address": { "city": "Boston", "zip": "02134" }, "tags": ["admin", "beta"] },
{ "id": 2, "name": "Omar, Jr.", "address": { "city": "Casablanca" }, "phone": "+212 600-000000" }
]CSV output
id,name,address.city,address.zip,tags,phone
1,Jane,Boston,02134,"[""admin"",""beta""]",
2,"Omar, Jr.",Casablanca,,,+212 600-000000The nested address becomes address.city and address.zip, the array is kept as JSON text in one cell, phone appears only on the second record but still gets its own column, and the comma in Omar, Jr. is quoted so it does not create an extra column.
Your data stays on your device. The conversion runs in JavaScript inside this tab — files and pasted text are never uploaded to DataSwitch Pro.
How nested JSON is flattened
Each nested object adds its key as a prefix, joined with a dot: {"a":{"b":{"c":1}}} becomes a column named a.b.c. Arrays are written as JSON text in a single cell, which preserves every element and keeps the number of columns predictable. If you prefer each nested object as raw JSON in one cell, untick Flatten nested JSON.
Records with different keys
Real-world JSON is rarely uniform. The converter scans every record and builds the column list from all keys, in the order they first appear. A record that lacks a key simply gets an empty cell, so you never lose fields that only exist on some records — a common failure of tools that look only at the first object.
Accepted JSON structures
- Array of objects: one row per object.
- API-style wrapper like
{"data":[…]}or{"results":[…]}: the inner array is detected and used. - Single object: one row.
- Array of values: one column called
value.
Quoting rules
Values that contain the delimiter, a double quote, a line break, or leading/trailing spaces are wrapped in double quotes, and quotes inside them are doubled — exactly what RFC 4180 specifies and what Excel, Google Sheets, pandas and databases expect. Other values are left unquoted to keep the file compact and readable.
Convert JSON to CSV in code
For one-off files the tool above is quickest. To automate the same task in a script or pipeline, these snippets are a good starting point.
Python (pandas)
import json
import pandas as pd
with open("data.json", encoding="utf-8") as f:
data = json.load(f)
pd.json_normalize(data).to_csv("data.csv", index=False, encoding="utf-8-sig")
Command line (jq)
# Flat JSON arrays only; nested values must be flattened first
jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json > data.csv
Frequently asked questions
Why do some cells contain text like ["a","b"]?
Those values were JSON arrays. Writing them as JSON text keeps all elements in one cell; split them later if you need separate columns.
My JSON is one big object, not an array. Will it work?
Yes. If the object wraps a single array (for example {"items": [...]}) the array is converted; otherwise the object becomes a single row.
How do I open the CSV in a European version of Excel?
Select Semicolon under Options → CSV output before downloading. Excel in French, German or Spanish locales then splits the columns correctly.
Can I convert the CSV back to JSON?
Yes. Click the swap button between the format menus and the CSV becomes the input of a CSV to JSON conversion.
Are large JSON files supported?
Yes. Files of several megabytes are converted in a background thread so the page stays responsive.