Free online tool

Upload a file

Drop your file hereTap to choose a file

or click to browse, or paste from the clipboard

← Back to Blog

How to Convert JSON to CSV or Excel (Nested Arrays and Long IDs)

To convert JSON to CSV, choose the array whose items should become rows, turn nested objects into dotted column names such as customer.zip, and decide what happens to arrays inside each row. For Excel, create an .xlsx file instead of opening a CSV, because Excel keeps only 15 digits of a number and strips leading zeros. The JSON to CSV Converter does all of this in your browser: it lists every array in your file, previews the columns and writes a CSV or an Excel workbook that keeps long IDs exact. Nothing is uploaded.

How to convert JSON to CSV with Zutilium

  1. Open the JSON to CSV Converter and leave Direction on JSON → CSV. Use Choose a file or paste into Or paste JSON. Files can be up to 10 MiB.
  2. Under Rows from, pick the array whose items should become rows. Each entry shows a path and a row count, such as $.orders · 2 rows, and the outermost array of objects is selected to start with.
  3. Under Nested arrays, keep JSON text in one cell or switch to Numbered columns.
  4. Leave Include parent fields ticked when the rows come from an inner array, so each row carries its parent's values.
  5. Choose a Delimiter: Comma, Semicolon or Tab. Tab saves a .tsv file.
  6. Select Download data.csv (the link takes your file's name if you chose a file) or Copy result. For a workbook, select Create Excel file, then Download data.xlsx.

The preview updates as you type or change a setting and shows up to 50 rows and 60 columns. The status line above it gives the table size, such as "3 rows × 7 columns from $.orders[*].items", the number of numeric columns, and any duplicate keys, where the last value wins.

Choose which array becomes rows

This API response holds two orders, each with a customer object, a list of tags and a list of line items:

{
  "page": 1,
  "orders": [
    {
      "id": 7302518493016572417,
      "customer": {"name": "José Muñoz", "zip": "02134"},
      "tags": ["gift", "express"],
      "items": [
        {"sku": "MUG-01", "qty": 2, "price": 12.50},
        {"sku": "TEA-07", "qty": 1, "price": 19.90}
      ]
    },
    {
      "id": 7302518493016572418,
      "customer": {"name": "Mia Chen", "zip": "80202"},
      "tags": [],
      "items": [
        {"sku": "MUG-01", "qty": 4, "price": 12.50}
      ],
      "coupon": "FALL10"
    }
  ]
}

Rows from offers four choices for this file. In each path, $ is the whole document and [*] means every element, so $.orders[*].items gathers the items of all orders.

Rows from Each row is Use it for
$.orders · 2 rows An order Order lists and counts
$.orders[*].items · 3 rows A line item Product sales, pivot tables
$.orders[*].tags · 2 rows A tag Counting tags
Whole document as one row The response Single records and settings

With line items as rows and Include parent fields on, the CSV looks like this:

orders.id,orders.customer.name,orders.customer.zip,orders.coupon,sku,qty,price
7302518493016572417,José Muñoz,02134,,MUG-01,2,12.50
7302518493016572417,José Muñoz,02134,,TEA-07,1,19.90
7302518493016572418,Mia Chen,80202,FALL10,MUG-01,4,12.50

Parent columns come first, prefixed with the parent array's name; when that array is the top level of the file, the prefix is parent. Only the parent item's own values are copied, so its other arrays (the tags) and top-level fields such as page are left out.

The repetition is deliberate: pivot tables and database joins need the order ID on every item row. If you later merge overlapping exports, remove repeats by whole row with the CSV Duplicate Remover, not by order ID, or you lose line items.

A record with two independent arrays needs two files: export the items, then the tags, and join them on orders.id. One table holding both would pair every item with every tag.

How to flatten nested JSON to CSV

Each level of nesting adds a part to the column name, joined by a dot, so {"customer": {"zip": "02134"}} gives a customer.zip column. Columns cover every key in any row, in first-seen order, so a key only some rows have, like coupon, leaves empty cells elsewhere. null and missing keys become empty cells, true and false are written as text, and an empty object is written as {}.

Arrays inside a row follow the Nested arrays setting:

Option Columns you get Best when
JSON text in one cell tags holds ["gift","express"] You'll parse the cell later, or arrays are long
Numbered columns tags.0, tags.1, items.0.sku … Arrays are short and similar in length
The array under Rows from One row per element You want to count, sum or filter elements

Numbered columns turns the two orders into 12 columns, five of them empty for the second order, and a single order with 40 items would need 120 item columns. The converter stops at 2,000 columns or 2 million cells. Cells kept as JSON text are valid JSON with numbers exactly as written, so any JSON parser can read them back.

How to convert JSON to Excel without losing digits

Excel guesses each value's type when it opens a CSV, and the guesses damage identifiers: it keeps 15 significant digits of a number and removes leading zeros, as Microsoft's guide to large numbers explains. JavaScript has its own limit: its numbers hold every integer exactly only up to 9,007,199,254,740,991, so a converter that reads the file with JSON.parse rounds longer IDs before Excel sees them.

Here is what happens to the sample's two order IDs, the price 12.50 and the ZIP code 02134:

Route IDs …417 and …418 12.50 02134
Converter built on JSON.parse Both 7302518493016573000 12.5 02134
CSV opened in Excel, default settings Both 7302518493016570000 12.5 2134
Zutilium Excel download Exact, stored as text 12.50, a number 02134

The first two routes give two different orders the same ID. Zutilium's CSV keeps every digit, but Excel still cuts them when it opens that CSV, so use Create Excel file for anything going into Excel.

In the workbook, a column becomes number cells only when every value is a plain JSON number of up to 15 significant digits, like qty and price, and shared decimal places are kept, so 12.50 still shows 12.50. Everything else, IDs included, is stored in Excel's Text format, and the header row is bold, frozen and filterable. There is no delimiter or encoding to guess either, and text that starts with =, which Excel may run as a formula when it opens a CSV, stays plain text.

Excel for Microsoft 365 and Excel 2024 let you turn these conversions off. On Windows, open File > Options > Data, clear Enable all default data conversions when entering, pasting, or loading text into Excel, and make sure Remove leading zeros and convert to a number and Keep first 15 digits of long numbers and display in scientific notation are cleared (Microsoft's data options). Digits that are already gone can't be recovered from the spreadsheet. If your data is already a CSV, the CSV to Excel Converter builds the same kind of workbook, as the guide to long order IDs in Excel shows.

Open JSON in Excel with Power Query

Excel can also import JSON itself with Power Query:

  1. In Excel for Windows, select Data > Get Data > From File > From JSON, choose the file and select Open, as in Microsoft's import steps. In Excel for Microsoft 365 for Mac, version 16.69 or later, select Data > Get Data, then Get Data (Power Query), and choose JSON.
  2. The Power Query Editor opens and flattens what it can into a table. Cells that still say Record or List hold nested data.
  3. Select the expand icon in that column's header. For a Record, tick the fields you want and select OK. For a List, choose Expand to New Rows to get one row per element, like picking an inner array under Rows from.
  4. Select Close & Load.

Power Query suits JSON you will refresh later, but plan around two limits. JSON numbers come in as numbers, and its Decimal number type, like a worksheet cell, holds 15 digits of precision (Power Query data types), so long IDs arrive with their last digits gone. And its JSON connector won't read JSON Lines files, which hold one object per line, without a custom step.

Convert JSON to CSV with jq or Python

For repeat jobs, script it. This jq command writes one row per line item with its order ID:

jq -r '.orders[] | .id as $id | .items[] | [$id, .sku, .qty, .price] | @csv' orders.json > items.csv
7302518493016572417,"MUG-01",2,12.50
7302518493016572417,"TEA-07",1,19.90
7302518493016572418,"MUG-01",4,12.50

Since version 1.7, jq keeps the original digits of numbers it doesn't change, as the jq manual describes; older versions round long IDs the way JavaScript does. You name every column yourself, and @csv accepts only arrays of plain values, so a nested object makes it stop with an error.

In Python, pandas flattens with json_normalize: record_path names the array that becomes rows and meta lists the parent fields to repeat, as the pandas documentation describes.

import json
import pandas as pd

with open("orders.json", encoding="utf-8") as f:
    data = json.load(f)

items = pd.json_normalize(
    data["orders"],
    record_path="items",
    meta=["id", ["customer", "name"]],
    meta_prefix="order.",
)
items.to_csv("items.csv", index=False, encoding="utf-8-sig")

The IDs stay exact, because Python's json module reads integers without rounding, but the prices become 12.5 and 19.9. encoding="utf-8-sig" adds the byte order mark Excel uses to recognize UTF-8. Without record_path, lists stay in one cell as Python text such as ['gift', 'express'], which is not valid JSON.

Troubleshooting

Accented names show up as José Muñoz

The CSV download is UTF-8 without a byte order mark (BOM). Microsoft notes that Excel opens a UTF-8 CSV normally when it has one (opening CSV UTF-8 files in Excel). Without it, Excel may read the file in an older code page, which turns é into é. Use Create Excel file instead, or import the CSV with Data > From Text/CSV and set File Origin to UTF-8 (code page 65001).

Every row lands in column A

Excel expected a different separator, common where the comma is the decimal mark. Choose Semicolon under Delimiter and download again, or use the Excel file, which has no separator.

IDs end in 000 or show as E+18

The digits were cut by a JavaScript-based converter or by Excel opening a CSV, and the spreadsheet can't give them back. Convert the original JSON again and use Create Excel file.

"Unexpected content after the root value at line 2, column 1"

The file is JSON Lines, with one object per line instead of one array. Wrap the lines in [ and ] with a comma after every line but the last, or run jq -s '.' input.jsonl > input.json and convert the result.

"Invalid JSON token at line 1, column 1" on a file that looks fine

The file is probably saved as UTF-16, and the converter reads files as UTF-8. Windows PowerShell 5.1 writes UTF-16 when you use > or Out-File, according to Microsoft's PowerShell encoding notes. Paste the text instead, or save the file as UTF-8. For other JSON errors, the line and column point at the problem, and the guide to invalid JSON covers the usual fixes.

"The result has more than 2,000 columns"

Numbered columns made a column for every array element. Switch to JSON text in one cell, or choose that array under Rows from instead.

Frequently asked questions

How do I convert a JSON file to CSV?

Open the JSON to CSV Converter, choose the file or paste the text, and pick the array that should become rows under Rows from. Check the preview, then download or copy the CSV.

Can I convert nested JSON to CSV?

Yes. Each column is named by its path through the objects, such as customer.zip. A list inside a row can stay whole in one cell, get a column per position, or become rows under Rows from.

How do I convert JSON to Excel?

Pick your rows in the converter and select Create Excel file. The .xlsx stores long IDs and leading zeros as text and quantities and prices as numbers. Excel's own From JSON import also works, but it keeps only 15 digits of each number.

Why does Excel change long numbers to E+18 or trailing zeros?

Excel stores numbers with 15 significant digits, so a 19-digit ID loses its last four and is shown in scientific notation. Use an .xlsx whose ID column is text, or turn off automatic data conversion before opening the CSV.

Why does my CSV show [object Object]?

A converter turned a nested object into text with JavaScript's default conversion, which prints [object Object] instead of the values. Convert again with one that flattens objects into columns, as Zutilium's does.

How do I convert CSV back to JSON?

Use the CSV to JSON Converter, which turns each row into an object and keeps codes such as 02134 as text. The guide to converting CSV to JSON explains its output shapes.