Skip to content

JSON to CSV, with nested arrays handled properly

Pick which array becomes the rows, decide what happens to each nested array, and see the row count before you download.

Your JSON is converted on this device and is never uploaded. How your data stays local.

Local
source
result
Loading the workspace...

JSON Mill's JSON to CSV converter turns an array of JSON records into CSV rows, one row per record and one column per field. Nested objects become dotted columns such as price.amount. For nested arrays you choose: join them into one cell, or write one row per nested item with the parent fields repeated.

It runs in your browser, so the file is never uploaded, and the export panel shows the row count, column count and approximate size before you download.

How to convert JSON to CSV

  1. Open your JSON. Paste it, drop a .json or .jsonl file on the workspace, or press Open file. Sample loads a small product catalog.
  2. Check the records. The Table view shows the records as a grid. JSON Mill exports the main array of records unless you type another path, such as data.items, into Records at in the export panel.
  3. Choose what happens to nested arrays. Open Export, keep CSV, and set Nested arrays to Join into one cell or One row per nested item. The summary line shows the new row count.
  4. Pick and rename columns. Under Columns, untick fields you do not need, edit a name to rename the header, and move columns up or down.
  5. Download. Press Download. JSON Mill adds a note if something needs attention, such as numbers Excel would round.

Example: orders with nested line items

Three orders, each with an items array. With One row per nested item, every line item gets its own row and the order fields repeat on each one.

orders.json
[
  {
    "order_id": "A-1001",
    "customer": "Rosa Diaz",
    "total": 54.5,
    "items": [
      { "sku": "MUG-01", "qty": 2, "price": 12.25 },
      { "sku": "TEA-07", "qty": 1, "price": 30.0 }
    ]
  },
  {
    "order_id": "A-1002",
    "customer": "Sam Okafor",
    "total": 19.99,
    "items": [
      { "sku": "BAG-03", "qty": 1, "price": 19.99 }
    ]
  },
  {
    "order_id": "A-1003",
    "customer": "Lena Hart",
    "total": 0,
    "items": []
  }
]
orders.csv with Nested arrays set to One row per nested item
order_idcustomertotalitems.skuitems.qtyitems.price
A-1001Rosa Diaz54.5MUG-01212.25
A-1001Rosa Diaz54.5TEA-07130.0
A-1002Sam Okafor19.99BAG-03119.99
A-1003Lena Hart0

Three orders with 2, 1 and 0 items become 4 rows: 2 + 1 for the orders with items, plus 1 for order A-1003, which keeps its row with empty item columns instead of disappearing. Numbers are written exactly as in the JSON, so 30.0 stays 30.0. With Join into one cell the same file gives 3 rows, with each order's items as compact JSON in one cell.

How JSON Mill flattens nested JSON

A CSV file is one flat table, so structure has to go somewhere. JSON Mill uses the same rules in the Table view and the export, so the grid you see is the file you get.

  • Nested objects become dotted columns: {"price": {"amount": "89.00"}} gives a price.amount column. Flattening goes up to three levels deep; deeper objects are written as compact JSON in one cell.
  • Arrays of plain values, such as tags, are joined into one cell with a semicolon and a space: camping; outdoor.
  • Arrays of objects, such as line items or variants, are written as compact JSON in join mode. In rows mode the largest nested array of objects becomes the rows, and any other nested arrays are joined.
  • Missing fields become empty cells. Columns come from every record, in the order they first appear, so a field only some records have still gets a column.
  • Duplicate keys in one object are flagged at export. Like JSON.parse, the export uses the last value, and JSON Mill names the keys and records affected.

What the CSV file looks like

JSON Mill writes RFC 4180 CSV: fields are quoted only when needed, lines end in CRLF unless you pick LF, and a UTF-8 byte order mark is on by default so Excel shows accented characters correctly. Turn it off under Cleaning if a script reads the file.

Number text is copied from your JSON, so 12345678901234567890 and 1.50 arrive unchanged. Text that starts with =, +, - or @ gets a leading apostrophe so a spreadsheet does not run it as a formula. Choose TSV for tab-separated values.

Compared with other ways to convert JSON to CSV

Common approaches to converting nested JSON to CSV
ApproachNested arraysWhere the data goesSkill needed
JSON Mill Your choice: joined cells or one row per item, with a row count first Stays in your browser None
Typical online converter Varies: often joined into one cell or spread into numbered columns, with no row count first Varies by site; some send the file to a server None
Python with pandas json_normalize One row per item through record_path and meta Stays on your machine Python
jq with @csv Whatever your filter builds Stays on your machine Command line and jq syntax
Excel Power Query Expand columns step by step Stays on your machine Excel and Power Query

Options

Settings in the workspace that matter for this job
Option What it does
Records at The array that becomes the rows. Leave it empty and JSON Mill picks the main array of records, preferring large, wide and shallow arrays. Type a path such as products, data.items or $.orders to choose another.
Nested arrays Join into one cell keeps one row per record. One row per nested item writes a row for each item of the largest nested array of objects and repeats the parent fields.
Columns Include or leave out each field, rename headers and change their order. Reset brings back every column with its original name.
Keep IDs as text Writes long numbers and codes with leading zeros as ="0123" so Excel keeps every digit. Other tools will see that literal text, so use it only for Excel.

Limits

  • Rows mode expands one nested array: the largest array of objects, by cell count. Other nested arrays are joined into one cell. JSON to Excel can put every nested array on its own sheet instead.
  • Nested objects are flattened to three levels. Anything deeper is written as compact JSON in one cell.
  • On arrays of more than 20,000 records, columns are found from a sample of 20,000 records spread across the array, so a field that appears in only a few records can be missed.
  • There is no custom delimiter setting. Choose CSV for commas or TSV for tabs.
  • In rows mode the export panel warns when the file would be larger than about 20 MB, or when the rows multiply ten times or more while a heavy column repeats on every row, and offers fixes such as dropping that column.

Questions

How do I convert nested JSON to CSV without losing array items?
Set Nested arrays to One row per nested item. Each item of the nested array gets its own row, and the parent record's fields are repeated on every row, so nothing is lost. A record whose array is empty still gets one row. The export panel shows the new row count before you download.
Can I convert a JSON object that is not an array?
Yes. If your file wraps the records in an object, such as {"data": {"items": [...]}}, JSON Mill finds the array of records inside it, searching up to six levels deep. If the whole document is a single object, it becomes a one-row CSV.
Will Excel change my numbers or IDs?
JSON Mill writes numbers exactly as in your JSON, but Excel rounds numbers past 15 significant digits and drops leading zeros when it opens a CSV. JSON Mill warns you when your data has such numbers. Turn on Keep IDs as text (or the Excel preset under Cleaning), or use JSON to Excel instead.
Does it work with JSON Lines files?
Yes. JSON Mill detects JSON Lines (NDJSON) from the content or a .jsonl or .ndjson name, checks each line, and exports each line as a row.
Is there a file size limit?
There is no fixed limit. JSON Mill asks before opening files over 25 MB, then opens them if you confirm. Your device's memory is the real ceiling; the large file viewer page has measured times.

Last updated