Skip to main content

JSON to CSV

Run Convert to see the result here.

Convert a JSON list of objects, or the first list of objects inside an object, to plain CSV text.

What it does

JSON to CSV turns JSON records into a plain table that a spreadsheet can open: one row per record, one column per name, and every value written as ordinary text.

It reads a list of objects, an object that holds such a list, or a single object. Nested objects become columns named with a dot path, such as address.city, and the tool tells you where the rows came from.

What it supports

  • Accepted: a list of objects, where each object is a row; an object that holds a list of objects, where the first such list is used; and a single object, which becomes one row. In a list at the top of the JSON, an item that is not an object, such as a number or a text, becomes a row with one column named value.
  • Where the rows come from: for an object, the tool goes through its members in the order they are written, going into nested objects before moving on, and uses the first list that is not empty and holds only objects. The result names its path, such as employees.employee. If there is no such list, the object itself is one row.
  • The header row lists every column found in any row, in the order each is first seen. A nested object adds one column per value, named with its path joined by dots, such as address.city. When a row has no value for a column, its cell is empty.
  • Cells are plain text. A text is written as it is, a number as it was written (9007199254740993, 2.370 and 1e400 come out unchanged), true and false as they are, and null as an empty cell. A nested list is written whole as compact JSON, such as [1,null], and an empty nested object as {}.
  • The file uses commas between cells and a CRLF line break between rows (the standard CSV line break). It is UTF-8 text with no byte order mark and no line break at the end. A cell is put in quotes only when it holds a comma, a double quote or a line break, and each double quote inside it is doubled.
  • An object with no members stays as a row of empty cells, as long as another row has at least one column. If no row has any column, the table would have none and the conversion is refused.

Good to know

  • Types are not kept: the text "1" and the number 1 both become 1, and null, an empty text and a missing name all become an empty cell. If you need the type of every value kept, JSON to YAML records it.
  • Only one list is used. When an object holds several lists of objects, the others are left out, and so are the members that sit next to the list. The result names the list that was used, so check that it is the one you wanted.
  • Two members that would get the same column name, such as a member called a.b and a member b inside an object a, are refused, because one value would overwrite the other. Names repeated inside one object, and strings with unpaired surrogate escapes, are refused as well, instead of guessed.
  • Spreadsheet risk: spreadsheet programs may reinterpret a file when you open it. A cell that starts with =, +, -, @, a tab or a carriage return and is not a plain number, such as =1+1 or @SUM(A1), is written exactly as it is, and a spreadsheet may run it as a formula; the tool shows a spreadsheet warning only when such a cell exists, header names included. Numbers, dates and numbers with leading zeros may also be retyped by a spreadsheet. The tool changes none of your data to prevent this: it adds no apostrophes and escapes nothing on your behalf.
  • When that warning appears, you must confirm that you understand the risk before you can copy or download. When you open the file in a spreadsheet, import it as text instead of double-clicking it, and know that retyping a cell can still turn it into a formula. This does not make opening a CSV file completely safe, and the site cannot promise that a file is safe in every spreadsheet program.
  • A table with many columns and many rows can produce a result larger than your input. If it passes the size limit, it is refused with an incomplete preview (see below).

How to use it

  1. Paste or type your JSON in the input box. It can be a list of objects, an object that holds a list of objects, or a single object. Nothing runs while you type.
  2. Press “Convert”. CSV has no indentation option.
  3. Read the CSV next to your input. When the rows were taken from inside an object, the result says which part, for example employees.employee. If a cell could run as a formula in a spreadsheet, a spreadsheet warning appears in the result area. If the conversion is refused, the message says why.
  4. Press “Copy” to put the CSV on your clipboard, or “Download” to save converted.csv. If the spreadsheet warning appeared, tick “I understand the spreadsheet risk described in the warning.” first: until you do, “Copy” and “Download” stay unavailable.

Examples

A list of records

Paste this JSON and press “Convert”. Each object becomes a row and each name becomes a column. Text comes out as written, without quotes, and numbers come out exactly as they were written. A cell is put in quotes only when it holds a comma, a double quote or a line break.

[{"id":1,"name":"Ada Lovelace","city":"London"},{"id":2,"name":"Grace Hopper","city":"New York"}]
id,name,city
1,Ada Lovelace,London
2,Grace Hopper,New York

An empty list

A list with no items has no rows to write, so the conversion is refused and the message says why.

[]

The array is empty. JSON to CSV needs at least one item to make a row.

Records inside an object

Many API responses wrap their records in an object. JSON to CSV goes through the object and uses the first list of objects it finds, here employees.employee, and the result names that path. The other members of the object are not in the CSV.

{"employees":{"employee":[{"id":"1","firstName":"Tom","lastName":"Cruise"},{"id":"2","firstName":"Maria","lastName":"Sharapova"}]}}
id,firstName,lastName
1,Tom,Cruise
2,Maria,Sharapova

Nested objects and lists

The object address becomes two columns, address.city and address.zip. The list tags stays whole in one cell as compact JSON, which is why that cell is in quotes (it holds commas and double quotes). true comes out as true and null becomes an empty cell.

[{"id":1,"address":{"city":"Recife","zip":"50000-000"},"tags":["a","b"],"active":true,"note":null}]
id,address.city,address.zip,tags,active,note
1,Recife,50000-000,"[""a"",""b""]",true,

Different values that look the same

A CSV cell is just text, so types are lost. The number 1 and the text "1" both come out as 1, and an empty text, null and a missing name all come out as an empty cell. The name late is missing from the first record.

[{"a":1,"s":"1","e":"","n":null},{"late":true}]
a,s,e,n,late
1,1,,,
,,,,true

Limits and privacy

Size limits

  • Input: up to 2,000,000 bytes of UTF-8 text (about 2 MB). Accented letters and emoji take more than one byte each. Larger input is rejected.
  • Result: also up to 2,000,000 bytes. If the complete result would be larger, the tool shows only an incomplete preview of the first 100,000 bytes, and that preview cannot be copied or downloaded.
  • Nesting: up to 256 levels of objects and lists inside each other. Deeper JSON is refused because it is beyond what the tool processes.
  • Time: a run that takes longer than its time limit is stopped. Try a smaller input.

Your privacy

The text you type or paste, or open from a local file, is processed locally in your browser, in a dedicated Web Worker. It is never uploaded or sent to the server (a file you open is read in your browser only), and it is not written to storage, cookies or the address bar.

“Copy” puts the result on your clipboard and “Download” saves it as a file, but only when you press the button. The file is created in your browser, so nothing is uploaded.

For the full details, see the Privacy Policy

Related tools and pages

Your text stays in the page when you switch tools in the same tab, so you can try the same text in another tool. Reloading or closing the tab ends it.

All tools