Flatten JSON for CSV Export

Convert nested JSON into stable column paths before exporting to CSV, Excel, Sheets, Power BI, or any reporting workflow that expects rows and columns.

Paste your JSON → Get results instantly (no signup)

⚡ Instant resultsNo signupRuns in your browser
Try examples:

Flatten or nest keys in this JSON structure and flatten nested object.

{
"user": {
"name": "Alice",
"address": {
"city": "NYC",
"zip": "10001"
}
}
}
Output
1{
2 "user.name": "Alice",
3 "user.address.city": "NYC",
4 "user.address.zip": "10001"
5}

Love the result?

Use this exact pipeline in your app, backend, or LLM workflow.

No setup needed. Works with curl, Node, Python.

Uses example data. For edited input, copy from the playground.

Read integration guide

Works with:

  • JSON to CSV conversion
  • Excel and Google Sheets
  • Power BI and Tableau
  • Reporting exports

Example: input → output

Flatten JSON before CSV export

CSV is a table format, so it cannot represent nested objects directly. If you convert nested JSON to CSV too early, fields like customer, address, and metadata often become stringified blobs in one cell. Flattening JSON first turns nested paths into useful columns such as customer.email, shipping.address.city, and plan.interval.

This page is for the spreadsheet and reporting workflow. It uses the same browser-based engine as the Flatten JSON tool, but the examples focus on CSV, Excel, Google Sheets, Power BI, Tableau, and BI handoffs.

Nested JSON to CSV-ready columns

Input:

[
  {
    "customer": {
      "email": "ada@example.com",
      "company": "Analytical Engines"
    },
    "invoice": {
      "total": 129,
      "currency": "USD"
    }
  }
]

Flattened output:

[
  {
    "customer.email": "ada@example.com",
    "customer.company": "Analytical Engines",
    "invoice.total": 129,
    "invoice.currency": "USD"
  }
]

Those keys become clean CSV headers. Finance, ops, and customer-success teams can filter by invoice.currency or customer.company without opening nested JSON in a single cell.

How to flatten JSON for Excel

  1. Paste the nested JSON array.
  2. Flatten nested objects into dotted paths.
  3. Check whether arrays should stay arrays or expand by index.
  4. Send the flat output to JSON to CSV or JSON to Excel.
  5. Open the CSV in Excel, Google Sheets, Numbers, or a BI tool.

If the data has inconsistent records, run Normalize JSON before export so each row has the same expected columns.

CSV edge cases

Flat JSON still needs a little care before CSV export. Long numeric IDs may be interpreted by Excel as numbers. Timestamps can be auto-converted to local date formats. Arrays can create either indexed columns or string values. Missing keys turn into empty cells. These are spreadsheet issues, not JSON issues, but flattening makes them easier to see before the export.

Flatten vs direct conversion

Direct JSON to CSV conversion is fine for already-flat arrays:

[{ "id": 1, "email": "ada@example.com" }]

Flatten first when the record contains objects:

[{ "user": { "id": 1, "email": "ada@example.com" } }]

Without flattening, the user object may become a string in one CSV cell. With flattening, user.id and user.email become separate columns.

Use Flatten JSON Array when child arrays are the hard part. Use Flatten API Response JSON when the source is a REST, GraphQL, or webhook payload. Return to the main JSON flattener for the general-purpose tool page and reverse nesting option.

Frequently asked questions

Why flatten JSON before converting to CSV?+

CSV is flat. Flattening first turns nested paths into column names, so fields like customer.email and invoice.total become separate columns instead of stringified objects.

Does flattened JSON work in Excel?+

Yes. After flattening, convert the flat JSON array to CSV and open it in Excel, Google Sheets, Numbers, Power BI, or Tableau.

What if my JSON records have different fields?+

You can still export them, but some cells will be empty. Normalize JSON first when every row needs the same set of columns.

Related tools

Read more on the blog

Advanced usage (optional)

Flatten / Nest

v1.0.0
Structure
objectarrayreversible

Description

Flatten / Nest

Convert between nested and flat object structures. Flatten deep objects into single-level key-value pairs, or nest flat keys back into hierarchical objects. Supports multiple key formats: delimiter-separated, camelCase, snake_case, PascalCase, and kebab-case.

Modes

Flatten

Convert nested objects into flat keys. Each nested path becomes part of the key name.

{ "user": { "name": "Alice" } }  →  { "user.name": "Alice" }

Nest

Convert flat keys back into nested objects by splitting on the delimiter or case boundaries.

{ "user.name": "Alice" }  →  { "user": { "name": "Alice" } }

Key Formats

Delimiter (default)

Join/split key segments with a character (default: .).

  • Flatten: user + nameuser.name
  • Nest: user.nameuser / name

camelCase

Join/split on uppercase letter boundaries.

  • Flatten: user + address + cityuserAddressCity
  • Nest: userAddressCityuser / address / city

snake_case

Join/split on underscores.

  • Flatten: user + address + cityuser_address_city
  • Nest: user_address_cityuser / address / city

PascalCase

Same as camelCase but with uppercase first letter.

  • Flatten: user + nameUserName

kebab-case

Join/split on hyphens.

  • Flatten: user + nameuser-name

Configuration

FieldTypeDefaultDescription
Modeenumflattenflatten or nest
Key Formatenumdelimiterdelimiter, camelCase, snake_case, PascalCase, or kebab-case
Delimiterstring.Character(s) used to join/split key segments (only for delimiter format)
Max Depthnumber0Maximum nesting depth to flatten (0 = unlimited)
Target Pathspath-picker[]Scope operation to specific paths only (empty = apply everywhere)

Use Cases

API Integration

  • Flatten for forms: Convert nested API responses to flat form field names
  • Nest for APIs: Convert flat form data back to nested API request bodies
  • Format conversion: Transform between dot-notation and camelCase conventions

Database Operations

  • MongoDB flattening: Flatten nested documents for tabular export
  • SQL mapping: Convert hierarchical JSON to flat column names for SQL insertion
  • Schema migration: Convert between naming conventions (snake_case ↔ camelCase)

Configuration Management

  • Environment variables: Flatten config objects to dot-notation for .env files
  • Depth limiting: Flatten only the first level while preserving deep structures

Configuration

NameTypeDefaultDescription
Modeenumflattenflatten: convert nested objects to flat keys. nest: convert flat keys back to nested objects. flatten nest
Key Formatenumdelimiterdelimiter: use a character to join/split. Others: camelCase, snake_case, PascalCase, kebab-case. delimiter camelCase snake_case PascalCase kebab-case
Delimiterstring.Character(s) used to join/split key segments (default is dot)
Max Depthnumber0Maximum nesting depth to flatten (0 = unlimited)
Target Pathspath-picker[]Scope operation to specific paths only (empty = apply everywhere)

Examples

AI Prompt
Flatten or nest keys in this JSON structure and flatten nested object.
{
"user": {
"name": "Alice",
"address": {
"city": "NYC",
"zip": "10001"
}
}
}
Output
1{
2 "user.name": "Alice",
3 "user.address.city": "NYC",
4 "user.address.zip": "10001"
5}
Config
Mode
flatten
Delimiter
.
Max Depth
0
Target Paths
all

API Usage

POST /api/v1/utilities/structure.flatten-nest
Example:
curl -X POST https://your-domain.com/api/v1/utilities/structure.flatten-nest \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs":{"primary":{"user":{"name":"Alice","address":{"city":"NYC","zip":"10001"}}}},"config":{"mode":"flatten","delimiter":".","maxDepth":0,"targetPaths":[]}}'
Response
1{
2 "user.name": "Alice",
3 "user.address.city": "NYC",
4 "user.address.zip": "10001"
5}