What does a JSON to CSV converter do?
JSON is a tree: objects inside objects, lists inside lists. CSV is a table: one header line, then one line per record, with the same columns in each. Spreadsheets, BI tools, database importers and mail-merge tools all want the table. Converting JSON to CSV is how an API response, a log export or a NoSQL dump ends up in Excel, Google Sheets or a COPY command.
The hard part is the shape. A list of objects maps naturally to rows, and the keys become the header. But real JSON has nested objects (address.city), lists inside a record (tags) and records that do not all have the same keys. This converter takes a stance on each: it collects every key that appears anywhere as a column, leaves a cell empty when a record lacks a key, and either flattens nested data into dotted column names or keeps it as JSON text in one cell, as you choose.
It runs in your browser, so the JSON you paste (a customer export, say) is never uploaded. It is also forgiving about input: besides strict JSON it reads relaxed JSON, such as single quotes, unquoted keys, comments and trailing commas. Numbers too large for a double keep every digit.
How to convert JSON to CSV
- Paste an array of objects, or a single object, in the Your raw JSON box. The page opens with a small example; Clear empties the box and Load example brings it back.
- The CSV appears below as you type, under CSV from your JSON.
- Leave Flatten nested objects on to turn nested objects and lists into one column each (
address.city,tags.0), or turn it off to keep them as JSON text inside a single cell. - Pick the Delimiter: comma, semicolon, tab or pipe. Use the semicolon for Excel in countries where the decimal separator is a comma, such as Brazil, Spain and much of Europe, and the tab for pasting straight into a spreadsheet.
- Press the copy button, then paste into a file named
something.csvor straight into a sheet. - If the JSON is invalid, a red message gives the line and column. If it is valid but not a list of objects or one object, the page tells you to wrap plain values in objects.
JSON to CSV examples
Nested objects and lists, flattened
Input:
[
{"id":1,"name":"Maria Silva","address":{"city":"São Paulo","zip":"01310-100"},"tags":["a","b"]},
{"id":2,"name":"João, Jr.","address":{"city":"Recife"},"tags":[],"vip":true}
]Output (comma delimiter, flatten on):
id,name,address.city,address.zip,tags.0,tags.1,tags,vip
1,Maria Silva,São Paulo,01310-100,a,b,,
2,"João, Jr.",Recife,,,,[],trueThe header is the union of all keys. The second record has no zip or tags.0, and the first has no vip, so those cells are empty. The comma in João, Jr. makes that field quoted.
The same data without flattening
With Flatten nested objects off, the header is id,name,address,tags,vip, and address holds the JSON text {"city":"São Paulo","zip":"01310-100"} in one quoted cell, with its inner quotes doubled.
A list inside each record
[{"pedido":1,"itens":[{"sku":"A","qtd":2},{"sku":"B","qtd":1}]}] flattens to:
pedido,itens.0.sku,itens.0.qtd,itens.1.sku,itens.1.qtd
1,A,2,B,1Quotes, line breaks and nulls
[{"q":"ele disse \"oi\"","l":"a\nb","n":null,"u":"x"}] gives:
q,l,n,u
"ele disse ""oi""","a
b",null,xFollowing RFC 4180, a field with a delimiter, a quote or a line break is wrapped in quotes and inner quotes are doubled. A JSON null is written as the word null, while a missing key leaves the cell empty.
Lists of plain values
[1,2,3] has no field names, so it becomes one column called value, one row per number, and a yellow notice explains it.
Common errors and how to fix them
- Invalid JSON at line 1, column 9: for example
[{"a":1 "b":2}], a missing comma. Add it at the position shown. - Invalid JSON at line 1, column 10: the text ends early, as in
[{"a":1},. Close the brackets, or copy the whole response. - The JSON must be a list of objects or a single object: the JSON is valid but is a bare string, number or boolean. Wrap it:
[{"value": 42}]. - The accents look broken in Excel: opening the file by double-click makes Excel guess the encoding. Use the import command (Data, From Text/CSV) and choose UTF-8, or paste straight into the sheet.
- Numbers lose a trailing zero:
19.90and18.0come out as19.9and18, because CSV is built from the number's value. Write such values as strings in the JSON to keep them as typed.
Frequently asked questions
How do I convert JSON to CSV online?
Paste the JSON array in the box and copy the CSV below it. Everything happens in your browser, with no sign-up and no upload. To check or format the JSON first, use the JSON formatter or the JSON validator.
What if the objects have different keys?
Every key that appears in any record becomes a column, in order of first appearance, and a record that lacks a key gets an empty cell. Nothing is dropped.
Can I convert JSON to Excel?
CSV opens in Excel and Google Sheets. For a real .xlsx file, convert here and then use CSV to XLSX. For the way back, XLSX to CSV gives you a CSV to turn into JSON with the data converter.
How do I convert CSV to JSON?
Paste the CSV into the data converter, pick CSV as the input and JSON as the output. It detects comma, semicolon, tab and pipe delimiters and can turn numbers and booleans into real types.
How to convert JSON to CSV in code
JavaScript
papaparse handles quoting and delimiters; flatten the records first if they are nested.
import Papa from 'papaparse';
const rows = JSON.parse('[{"id":1,"name":"Maria Silva"},{"id":2,"name":"João, Jr."}]');
console.log(Papa.unparse(rows, { delimiter: ';' }));Python
csv.DictWriter writes flat records; for nested JSON, pandas.json_normalize flattens it with the same dotted names.
import csv
import json
import sys
rows = json.load(open("data.json", encoding="utf-8"))
writer = csv.DictWriter(sys.stdout, fieldnames=rows[0].keys())
writer.writeheader()
writer.writerows(rows)Booleans come out as True and False in Python, not true and false.
Bash
jq can print CSV; this assumes every record has the same keys as the first.
jq -r '(.[0]|keys_unsorted) as $k | $k, (.[]|[.[$k[]]]) | @csv' data.json