Nested JSON to CSV: arrays, missing fields, and spreadsheet checks

Converting nested JSON to CSV changes a hierarchy into rows and columns. Decide how to handle nested objects, arrays, and empty values before you open the result in a spreadsheet.

Decide what one row is supposed to represent

An API can return a customer object inside an order and several tags inside an array. A spreadsheet needs a column for each value. Before exporting, decide whether one row represents an order, a customer, or an item. Flattening the input cannot make that choice for you.

Utilza's conversion uses one row per top-level object. A nested object can become dot-path columns such as customer.city. An array inside that object stays in one cell as JSON text. It does not create a new row for each tag or item.

Keep the JSON source alongside the CSV. An explicit null and a missing field both become empty cells, so the table cannot tell them apart afterward. If that distinction affects a report, add an explicit status field in your export process before converting.

Convert nested JSON to CSV and inspect what changed

Open JSON Viewer to inspect the top-level shape and locate the records you need. If the response is an object containing an orders array, copy that array when you want one row per order. A top-level wrapper object otherwise becomes a single row. If parsing fails, follow the guide to finding the first invalid JSON error before converting.

Then open JSON to CSV, keep Flatten nested objects and Include header row enabled, and choose a delimiter. This compact input shows the two different kinds of nesting:

[
  {"id":"00123","customer":{"city":"Lisbon"},"tags":["new","retail"],"optional":null},
  {"id":"00456","customer":{"city":"Paris"},"tags":[]}
]

The resulting columns are id, customer.city, tags, and optional:

id,customer.city,tags,optional
00123,Lisbon,"[""new"",""retail""]",
00456,Paris,[],

The doubled quotes in the tags cell are CSV escaping. After a CSV parser reads the cell, its value is ["new","retail"]. Both optional cells are empty even though the first input explicitly contained null and the second omitted the key.

A local fixture run on October 27, 2026 used Utilza's current JSON parser and CSV helpers in Node.js v24.15.0. It checked nested objects, string arrays, missing keys, null, 00123, a comma, an embedded quote, a line break, and =1+1. The raw CSV retained the leading-zero text and quoted the comma, quote, and multiline fields. This tests the converter's output; it does not prove how every spreadsheet will import those cells.

Before opening untrusted records in a spreadsheet, enable Excel-safe. In this tool it adds a UTF-8 byte order mark and prefixes cells starting with =, +, -, @, a tab, or a carriage return with an apostrophe. The fixture's =1+1 became '=1+1. That prefix changes the stored cell text. Keep formulas from unknown exports disabled.

Import identifiers such as ZIP codes and product codes as text in your spreadsheet. CSV quoting, including "00123", does not by itself tell the spreadsheet that a column must remain text. Use its import controls to choose the delimiter and column types.

You can pass the CSV through CSV to JSON to inspect the table again. With Convert types enabled, the tested 00123 stayed a string and empty cells became null. The key customer.city stayed a literal key, and the tags cell stayed a string. Reversing the file format does not rebuild the original hierarchy.

The converter's quoting follows the rules described in RFC 4180: a field containing a delimiter, a quote, or a line break is quoted, and an embedded double quote is doubled. Those rules protect the table structure; they do not preserve JSON types or control spreadsheet formulas.

Export nested JSON to CSV for a spreadsheet

  1. Keep the original JSON. Inspect it in JSON Viewer and identify the top-level array whose objects should become rows.
  2. Copy that array into JSON to CSV, or upload a JSON file within the 5 MB input limit. Fix any parse error before exporting.
  3. Enable Flatten nested objects and Include header row when you need dotted column names and a named header. Choose the delimiter your destination expects.
  4. Enable Excel-safe before opening untrusted records in a spreadsheet. Check whether apostrophe prefixes affect any values your downstream system expects.
  5. Check array cells, empty cells, identifiers with leading zeros, and fields with commas or line breaks. The preview shows the first 100 rows; copy or download contains the full converted table.
  6. Download the CSV. Import it with explicit delimiter and text-column settings, then check representative rows in the destination.
  7. If needed, inspect a copy in CSV to JSON. Compare values against the original JSON and account for flat dotted keys, array text, and the loss of the missing-versus-null distinction.

Where a flat CSV cannot stand in for the source JSON

  • Input is limited to 5 MB. A preview of 100 rows is not evidence that the download was truncated; check the output row count.
  • Nested arrays stay as JSON text in one cell. The converter does not expand line items into multiple rows or separate relational tables.
  • Null, missing keys, and empty strings can all produce empty CSV cells. Add explicit markers before conversion if you need to distinguish them.
  • Dotted paths are column names. Converting the CSV back does not recreate nested objects or parse array cells automatically.
  • Flattening can collide with a literal dotted key. Avoid input that contains both customer.city and customer: {city: ...} unless you rename one first.
  • CSV has no column-type schema. Check spreadsheet imports for leading zeros, long identifiers, date-like text, and formula behavior.
  • Excel-safe changes some values by adding an apostrophe. Review the result before sending it to a database or another non-spreadsheet importer.

Frequently asked questions

Does converting nested JSON to CSV create rows for every array item?

No. Each top-level object becomes one row. Arrays inside an object stay as JSON text in a cell; they are not expanded into extra rows.

Can I distinguish null from a missing field in the CSV?

Not from the empty cell alone. Both become empty cells in this converter. Add an explicit marker or status field before conversion when that difference matters.

Why did my spreadsheet remove the leading zeros from an ID?

The CSV can contain the original digits while the spreadsheet imports the column as numbers. Use the spreadsheet import controls to mark identifier columns as text.

Will converting the CSV back to JSON restore the original nested data?

No. Dotted headers remain literal keys, and array cells remain text. Empty cells can become null when Convert types is enabled. Keep the original JSON for the full structure.

Tools used in this guide

  • JSON ViewerDeveloper Tools

    Shows JSON as a collapsible tree with search and copyable paths.

  • JSON to CSVConverters

    Turns an array of JSON objects into a CSV table.

  • CSV to JSONConverters

    Turns a CSV table into an array of JSON objects.

More from the blog

All guides