Converting Nested JSON to Flat CSV: Handling Complex Data Structures

Converting nested JSON to CSV requires 'flattening' — nested objects become dot-notation column headers (user.name, user.address.city). Arrays require either expansion or serialization decisions.

Nested JSON object structure being flattened to CSV columns with dot-notation headers

JSON Flattening: The Core Problem

Deeply nested JSON tree versus normalized 2D flat CSV spreadsheet comparison

Recursive dot notation key flattening algorithm for nested JSON properties

CSV is inherently flat — it has rows and columns. JSON can be arbitrarily nested — objects within objects within arrays. Converting JSON to CSV requires resolving this structural mismatch.

Simple JSON (easy to convert):

[
  {"id": 1, "name": "Alex", "age": 30},
  {"id": 2, "name": "Maria", "age": 25}
]

Result: 3 columns (id, name, age), 2 data rows.

Nested JSON (requires flattening):

[
  {"id": 1, "user": {"name": "Alex", "address": {"city": "Boston", "zip": "02101"}}}
]

Flattened result: 4 columns (id, user.name, user.address.city, user.address.zip), 1 data row.


Handling JSON Arrays in CSV Conversion

RFC 4180 CSV escaping rules for quotes, commas, and newlines with Excel UTF-8 BOM fix

Strategies for handling nested arrays in CSV showing unrolled rows versus delimited strings

Option 1: Row expansion Each array element becomes a separate row, with parent object fields duplicated:

{"order_id": 1, "items": [{"sku": "A"}, {"sku": "B"}]}

Becomes 2 CSV rows:

order_id,items.sku
1,A
1,B

Option 2: JSON string serialization The array is stored as a JSON string in a single CSV cell:

order_id,items
1,"[{""sku"":""A""},{""sku"":""B""}]"

Row expansion is usually better for analysis in Excel. Serialization is better when the array will be reparsed by code.


Step-by-Step: JSON to CSV on ToolDolfen

ToolDolfen in-browser JSON to CSV spreadsheet converter workflow pipeline

  1. Open the ToolDolfen JSON to CSV converter.
  2. Paste your JSON data (array of objects preferred for CSV conversion).
  3. Configure:

- Array handling: expand to multiple rows or serialize to string - Delimiter: comma (default) or semicolon for European Excel formats

  1. Click Convert.
  2. Download your CSV file for Excel, Google Sheets, or data pipeline use.

Recommended Companion Guides

Explore complementary tutorials and utilities from this topic cluster to enhance your digital workflow:

The Modern Favicon Guide: ICO, PNG, SVG, and Web App ManifestsPractical step-by-step tutorial with verified standards and in-browser workflows.How to Format & Minify Large JSON Files in Your BrowserPractical step-by-step tutorial with verified standards and in-browser workflows.The Modern Regex Cheatsheet: Practical Patterns, Syntax & Validation GuidePractical step-by-step tutorial with verified standards and in-browser workflows.How to Convert PDF to Editable Word (DOCX): Accuracy and Format PreservationComplementary cross-format workflow connecting related data and media tools.
Recommended Utility: JSON to CSVExecute this workflow live in your browser with zero server uploads and 100% client-side privacy.
Convert JSON to CSV →
Launch Tool →

Frequently Asked Questions

Find quick, verified answers to common questions regarding this workflow.

What happens to JSON arrays when converting to CSV?

Arrays can be handled in two ways: expansion (each array element becomes a separate CSV row, duplicating the parent object's fields) or serialization (the array is stored as a JSON string in a single CSV cell). The right choice depends on your downstream use case.

How are nested objects handled in JSON to CSV conversion?

Nested objects are flattened using dot notation. A JSON object like {"user": {"name": "Alex", "age": 30}} becomes two CSV columns: user.name and user.age.

Bilal Ahmad