Skip to content
All Online Tools

How to convert JSON to CSV, and open it cleanly in Excel

, 6 min read

The quickest way to convert JSON to CSV is to drop the .json file into JSON to CSV and download the result. Each object in your JSON array becomes a row, each key becomes a column, and nested objects are spread out into their own columns. The file is read in your browser and never uploaded, which is useful when the JSON is an export of customers, orders or logs.

Whether the result is a tidy table depends on the shape of the JSON. That part is worth two minutes of understanding.

The shape that converts cleanly

CSV is a flat table, so the ideal JSON is a list of similar objects:

[
  { "id": 1, "name": "Ava", "city": "Denver" },
  { "id": 2, "name": "Liam", "city": "Austin" }
]

That becomes three columns, id, name and city, with one row per person. Most API responses and database exports look like this, or contain a list like this inside them.

What happens to everything else

  • Nested objects are flattened into columns with dotted names. "address": { "city": "Denver", "zip": "80202" } becomes two columns, address.city and address.zip.
  • Arrays inside a record, such as a list of tags or order items, are kept as JSON text in a single cell, for example ["red","blue"]. A table can't hold a list in one row without either repeating the row or inventing columns, so the data is kept intact for you to split later.
  • Missing keys leave a blank cell. If only some records have a "phone" key, the phone column exists and is empty for the rest. Columns appear in the order the converter first sees them.
  • An object whose values are all lists, like { "customers": [...], "orders": [...] }, produces one CSV for each list. JSON to Excel puts them on separate sheets of one workbook instead.
  • A single object becomes a one-row table.

Problems you might hit

  • "Unexpected token" errors. The file isn't valid JSON. A common cause is JSON Lines (.jsonl or .ndjson), where each line is its own object. Wrap the lines in square brackets and put a comma at the end of every line except the last, and it becomes a normal JSON array.
  • Long ID numbers change. Numbers above 9,007,199,254,740,991 can't be stored exactly in JavaScript, Excel or most spreadsheet tools, so the last digits get rounded. If your IDs are that long, have the source system export them as strings in quotes. Excel also shows only 15 significant digits and switches long numbers to scientific notation, so format those columns as Text when you import.
  • Accents or emoji look garbled in Excel. The CSV starts with a UTF-8 marker so Excel reads it correctly. If you edit the file in another program and the problem appears, our guide to fixing garbled CSV text in Excel applies to any language.
  • Everything lands in column A. Excel in many European locales expects semicolons. Pick Semicolon in the Delimiter option, or convert an existing file with Change CSV Delimiter.

When to pick Excel instead of CSV

If the goal is to look at the data, sort it or share it with someone who will open it in Excel, convert straight to a spreadsheet with JSON to Excel. You skip the import step, and multiple lists land on separate sheets. Choose CSV when the file is headed into another system: a CRM import, a mailing tool, a database or a script. Our guide to preparing a spreadsheet that will import covers what those systems usually reject.

Going the other way is just as quick: CSV to JSON turns rows back into a list of objects.

Other ways to do it

Excel for Windows can import JSON directly: Data > Get Data > From File > From JSON. It opens Power Query, where you click To Table and then the expand icon on each column. It handles very large files and can refresh from the same source later, but it takes more clicks for a one-off.

Python with pandas flattens nested objects the same way:

import json, pandas as pd
data = json.load(open("data.json"))
pd.json_normalize(data).to_csv("data.csv", index=False)

jq on the command line works for flat records, using the first object's keys as the header:

jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json > data.csv

For most people with a file to convert today, the browser route is the fastest, and the data stays on your computer.