Data & Formats

JSON ⇄ CSV Converter

Turn a JSON array into a CSV table, or a CSV file into JSON. Handles quoted fields, embedded commas and line breaks, and several delimiters.

Guide: JSON to CSV and Back: Quotes, Delimiters and Formulas

Ready.

What it does

Converts between JSON and CSV entirely in your browser. For JSON to CSV, the input should be an array of objects (each object becomes a row, and the columns are the union of all keys), an array of arrays, or a single object.

Details

  • Nested objects and arrays are written into a cell as JSON text.
  • Cells that contain the delimiter, quotes or line breaks are quoted, and quotes are doubled, following RFC 4180.
  • For CSV to JSON, numbers, true, false and null are detected only when they round-trip exactly, so values such as 007 or 1.10 stay text.
  • "Protect against spreadsheet formulas" prefixes text cells starting with = + - @ with an apostrophe, which stops Excel or Sheets from running them as formulas.

Example

This JSON array becomes a three-column table. The second object has no city key, so that cell is left empty, and the comma inside "Lee, Ann" is quoted:

[{"name":"Lee, Ann","age":31,"city":"Oslo"},{"name":"Raj","age":"n/a"}]

name,age,city
"Lee, Ann",31,Oslo
Raj,n/a,

Limits and common mistakes

  • The delimiter is chosen by you (comma, semicolon, tab or pipe), not detected. Spreadsheets in many European locales save semicolon-separated files, so a CSV that comes out as one wide column usually needs the semicolon option.
  • With "first row is header" turned on, the first CSV row supplies the key names. Repeated or empty names are reported, because an object holds one value per key and a repeated name keeps only the last column. Rows with extra fields get keys such as column4.
  • With the header option off, CSV to JSON returns an array of arrays instead of objects.
  • JSON to CSV does not flatten nesting. If you need one column per nested field, flatten the data first; otherwise the nested value is stored as JSON text in one cell.
  • Formula protection changes the data: a text value such as -5 gets a leading apostrophe. Turn it off when the file is for a program rather than a spreadsheet.
  • The whole input is held in memory as text, so very large files are better handled by a streaming command-line tool.

To check or tidy the JSON before converting, use the JSON Validator or JSON Formatter. To inspect a CSV as a sortable table, open it in the CSV Viewer. For a file with one JSON object per line, the NDJSON tool is the better fit.

Examples

This JSON:

[{"id":1,"name":"Ada, Countess","tags":["a","b"],"note":"say \"hi\""},{"id":2,"name":"=SUM(A1)","extra":true}]

becomes this CSV. The columns are the union of all keys, a missing value is left empty, a cell with a comma or quotes is quoted with the quotes doubled, and the array in tags is written as JSON text inside the cell:

id,name,tags,note,extra
1,"Ada, Countess","[""a"",""b""]","say ""hi""",
2,=SUM(A1),,,true

Look at the last row: a cell that starts with = is a formula when you open the file in a spreadsheet program. The option “Protect against spreadsheet formulas”, which is off by default, adds a leading apostrophe to cells that start with =, +, - or @, so =SUM(A1) becomes '=SUM(A1). Turn it on whenever the data comes from users.

CSV to JSON and types

For this CSV:

id,price,flag,empty,zip
1,9.50,true,,007
2,1e3,false,null,12345

the result keeps "price": "9.50", "1e3" and "zip": "007" as strings, because turning them into numbers would change them (9.5, 1000 and 7). Only values that survive the conversion exactly become numbers: 1 and 12345. The words true and false become booleans, the literal word null becomes null and an empty cell stays an empty string.

Frequently asked questions

What if my file uses semicolons or tabs?

Choose the delimiter in the options. Spreadsheet programs in countries where the decimal separator is a comma often export semicolons.

Does it follow a standard?

Quoting follows RFC 4180: cells with the delimiter, quotes or line breaks are quoted and quotes are doubled.

How do I view a CSV file as a table first?

Use the CSV Viewer.

Is my data uploaded?

No. The conversion runs in your browser.

Privacy

This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.

Share this tool

Your data is not included in this link.