JSON ↔ CSV Converter

Convert JSON arrays to CSV and CSV back to JSON, both ways

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

  1. 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.
  2. 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.
  3. 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, false and null into real JSON types instead of strings.
  4. Copy the output with the Copy button or Ctrl+Shift+C. Ctrl+L clears 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 active key the first one lacks, so the first row gets an empty cell for it, and the second row gets empty cells for address.* and tags. Nothing gets silently dropped because the first object happened to be missing a field.
  • Nested objects are flattened into parent.child columns. That’s what most spreadsheet users want, and it’s the convention pandas’ json_normalize uses 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 why Smith, John didn’t split into two columns.
  • null becomes 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:

  • 00451 stays a string. A JSON number can’t have a leading zero, and converting it would turn a product code, ZIP code or phone extension into 451.
  • 3,50 stays 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, false and null become booleans and null. TRUE, yes and 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

JSONCSV
StructureNested objects and arraysFlat rows and columns
TypesString, number, boolean, nullEverything is text
SchemaEach object can differEvery row shares one header
SizeKeys repeat on every recordKeys appear once, so it’s usually smaller
Best forAPIs, configs, document databasesSpreadsheets, 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.

Frequently Asked Questions

How do I convert JSON to CSV?

Paste a JSON array of objects, such as [{"name":"Ada","age":36}], and press To CSV or Ctrl+Enter. Every distinct key becomes a column header and every object becomes one row. Copy the result and open it in Excel, Google Sheets or a database import tool.

How are nested JSON objects converted to CSV?

With Nested keys (a.b) ticked, nested objects are flattened into dot-notation columns, so {"address":{"city":"Paris"}} becomes a column named address.city. Arrays are kept as one JSON-encoded cell, for example ["a","b"]. Untick the option to keep each top-level nested object as a JSON string in a single column.

Why do my CSV columns all end up in one cell in Excel?

Excel splits CSV files using your system list separator. In many European locales that is a semicolon, not a comma, so a comma-separated file opens as a single column. Set the Delimiter to Semicolon before converting, or use Excel's Data > From Text/CSV import and pick the comma delimiter explicitly.

Does CSV to JSON keep leading zeros in ZIP codes and IDs?

Yes. With Detect types on, only values that are valid JSON numbers become numbers, so 02134 or 007 stay strings and keep their zeros. Integers too large to represent exactly in JavaScript (beyond 9007199254740991) also stay strings. Turn Detect types off to keep every value as a string.

Which CSV delimiters are supported?

Comma, semicolon, tab (TSV) and pipe. In Auto mode the converter reads the header row and picks the separator that appears most often outside quotes. When converting JSON to CSV, Auto means comma; choose another delimiter from the menu to change it.

Does it handle quoted CSV fields with commas and line breaks?

Yes. The parser follows RFC 4180: a field wrapped in double quotes may contain the delimiter, line breaks, and doubled quotes as an escaped quote character. Windows CRLF line endings and the UTF-8 byte order mark that Excel adds are handled too, so they never leak into your keys.

Is my data uploaded anywhere?

No. Both conversions run in JavaScript inside your browser tab. Nothing is sent to a server, so it is safe to convert exports that contain customer records, API responses or credentials.