What is a JSON to CSV converter?
JSON (JavaScript Object Notation) is the format APIs, NoSQL databases and config files speak. It can nest objects inside objects and lists inside lists. CSV (Comma-Separated Values) is a flat table: one header row, then one line per record, with values separated by a delimiter. CSV is what spreadsheets, BI tools, bulk-import screens and COPY commands in SQL databases expect.
A JSON to CSV converter maps between the two. Each object in a JSON array becomes a CSV row, and each key becomes a column. Going the other way, each CSV row becomes a JSON object whose keys come from the header row. This page does both directions in one place. The tool auto-detects which way you’re converting and runs entirely in your browser.
How to use this tool
- Paste your data into the input box. It can be a JSON array (or a single JSON object) or CSV text with a header row.
- Press Ctrl+Enter, or click the highlighted button. If the input starts with
[or{, the tool treats it as JSON and highlights To CSV. Anything else is treated as CSV and highlights To JSON. You can always click the other button yourself. - Adjust the options if needed. Changing an option re-runs the last conversion right away:
- Delimiter: Auto, comma, semicolon, tab or pipe.
- Nested keys (a.b): flatten nested objects into dotted columns, and rebuild them from dotted headers.
- Detect types: turn
42,true,falseandnullinto real JSON types instead of strings.
- Copy the output with the Copy button or
Ctrl+Shift+C.Ctrl+Lclears the workspace.
Your last input is saved in your browser’s local storage, so it’s still there if you reload the page.
Converting JSON to CSV
Given this input:
[
{"id": 1, "name": "Smith, John", "address": {"city": "Paris", "zip": "75001"}, "tags": ["admin", "beta"]},
{"id": 2, "name": "Ada", "active": true}
]
the converter produces:
id,name,address.city,address.zip,tags,active
1,"Smith, John",Paris,75001,"[""admin"",""beta""]",
2,Ada,,,,true
The tool handles a few things here that naive converters get wrong:
- The header is the union of all keys, in the order they first appear. The second object has an
activekey the first one lacks, so the first row gets an empty cell for it, and the second row gets empty cells foraddress.*andtags. Nothing gets silently dropped because the first object happened to be missing a field. - Nested objects are flattened into
parent.childcolumns. That’s what most spreadsheet users want, and it’s the convention pandas’json_normalizeuses too. - Arrays stay in one cell as compact JSON. A list has no natural column layout, since you’d need a variable number of columns. A JSON string keeps it lossless, and the CSV to JSON direction leaves it readable.
- Escaping follows RFC 4180. A value containing the delimiter, a double quote or a line break is wrapped in quotes, and inner quotes are doubled (
"becomes""). That’s whySmith, Johndidn’t split into two columns. nullbecomes an empty cell. Lines end with CRLF (\r\n), the line ending RFC 4180 specifies and that Excel writes itself.
A single top-level object is treated as an array of one row. An array of plain values like [1, 2, 3] becomes a one-column CSV with the header value.
Converting CSV to JSON
The first CSV row supplies the keys. Each later row becomes one object:
name;price;sku;stock.warehouse
Tea;3,50;00451;Berlin
becomes (with Auto delimiter, Nested keys and Detect types on):
[
{
"name": "Tea",
"price": "3,50",
"sku": "00451",
"stock": {
"warehouse": "Berlin"
}
}
]
Auto-detection picked the semicolon because it appears three times in the header row and the comma doesn’t appear at all. 3,50 therefore stays one value. Note what the type detection didn’t do:
00451stays a string. A JSON number can’t have a leading zero, and converting it would turn a product code, ZIP code or phone extension into451.3,50stays a string because a decimal comma isn’t JSON number syntax. Convert it in your own code if you need a number.- Only exact
true,falseandnullbecome booleans and null.TRUE,yesand empty cells stay strings, and empty cells become"". - Integers beyond 2^53 − 1 (such as 19-digit database IDs or Twitter/X snowflake IDs) stay strings, because JavaScript would silently round them.
Dotted headers like stock.warehouse are rebuilt into nested objects, so flattening and unflattening round-trip cleanly. If a CSV also has a plain stock column, nesting would collide with it, so the dotted column is kept as a flat key instead. Blank headers are named column1, column2 and so on, and short rows are padded with empty strings.
Common JSON ↔ CSV problems and fixes
“Unexpected token” when converting JSON. The input isn’t valid JSON. Typical causes are trailing commas, single-quoted strings, unquoted keys, or JSON Lines (one object per line with no surrounding [ ]). Run it through the JSON Formatter to find the exact line. For JSON Lines, wrap the lines in brackets and add commas between them.
Everything lands in column A in Excel. Excel uses your operating system’s list separator, which is a semicolon in Germany, France, Italy, Brazil and many other locales. Convert with the Semicolon delimiter, or import through Data → From Text/CSV and choose the delimiter yourself.
Accented characters look like é in Excel. Older Excel versions assume a legacy code page unless a UTF-8 file starts with a byte order mark. Save the CSV as “UTF-8 with BOM” in your editor, or use the import wizard and set the file origin to UTF-8. When reading CSV, this tool strips a leading BOM automatically. Without that, it would end up glued to the first header name ("id" instead of "id"), a classic bug in hand-written parsers.
Rows break in the middle of a value. A quoted field contains a line break. That’s valid CSV, but splitting the file on newlines breaks it. This parser reads the whole text with a quote-aware state machine, so multi-line fields such as addresses or comments stay intact. The opposite problem, an unclosed quote, is reported as an error instead of quietly swallowing the rest of the file.
Numbers turn into dates or lose precision in Excel. That’s Excel’s import-time guessing, not the CSV itself. Values like 1-2 or MAR1 become dates, and long IDs become 1.23E+18. Use the import wizard and mark those columns as Text.
Columns are missing after conversion. Some converters build the header from the first object only. This one scans every object, so optional fields that only appear in later records still get a column.
JSON vs CSV: when to use which
| JSON | CSV | |
|---|---|---|
| Structure | Nested objects and arrays | Flat rows and columns |
| Types | String, number, boolean, null | Everything is text |
| Schema | Each object can differ | Every row shares one header |
| Size | Keys repeat on every record | Keys appear once, so it’s usually smaller |
| Best for | APIs, configs, document databases | Spreadsheets, analytics, bulk imports |
Use CSV when a person will open the data in a spreadsheet or when a tool imports tables, like PostgreSQL COPY, BigQuery or Airtable. Use JSON when the data has real hierarchy or mixed types, or when it’s headed to an API. If your target is a document rather than a spreadsheet, the Markdown Table Generator turns tabular data into a table for READMEs and docs.
Doing the same conversion in code
For repeatable pipelines, a few lines of code beat copy and paste. In Python, pandas.json_normalize(data).to_csv("out.csv", index=False) flattens nested objects with the same dot convention used here. pandas.read_csv(path, dtype=str) reads every value as a string, the equivalent of turning off Detect types. On the command line, jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' converts a flat JSON array. Note that this jq one-liner takes its columns from the first object only. In JavaScript, libraries such as Papa Parse handle streaming and very large files.
For a quick one-off conversion, an export you need to inspect, or data you’d rather not upload to an online service, this page does the same job with nothing to install. To pull a single field out of a large JSON response before converting it, try the JSON Path Tester.