Flatten Nested JSON Online (Free & Fast)

Flatten deeply nested JSON into a single level — predictable key paths, no scripts.

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:

  • Deeply nested API responses
  • Analytics event payloads
  • JSON destined for spreadsheet tools

Example: input → output

Input / Output
Input
{
"user": {
"name": "Alice",
"address": {
"city": "NYC",
"zip": "10001"
}
}
}
Output
{
"user.name": "Alice",
"user.address.city": "NYC",
"user.address.zip": "10001"
}

About this tool

Flattening nested JSON converts deep object hierarchies into a single level where each key encodes its full path. A field at user.address.city becomes user.address.city at the top level of the output. The reverse operation — nesting — takes flat keys with a delimiter and rebuilds the original shape. Both directions are useful, and which one you need depends on what consumes the data next.

The most common reason to flatten is preparing JSON for a tool that doesn't speak nested objects: CSV exports, BI dashboards, spreadsheet imports, or older databases. A row with user.name and user.email columns reads cleanly; the same row with a stringified { name: ..., email: ... } blob does not. Flattening solves this once at the boundary instead of every time downstream.

Analytics event payloads are another classic input. They tend to be deeply nested with a mix of identifiers, timestamps, and nested context — and they tend to be processed in pipelines that prefer flat keys. Flatten once, hand the result to whichever tool consumes it, and skip the per-event reshape step entirely.

This tool gives you control over the delimiter (., _, /), the casing of generated keys, and the maximum depth. Output is plain JSON with the same value types as the input — strings stay strings, numbers stay numbers, arrays stay arrays. There is no schema generation step; if your input round-trips back through the nesting direction, you'll recover the original shape exactly.

Frequently asked questions

What does flattening JSON mean?+

Flattening turns a deeply nested object into a single level where each key encodes its full path. A value at user.address.city becomes the key 'user.address.city' at the top level of the output.

Can I un-flatten the result back into nested JSON?+

Yes. The same tool runs in reverse — pick the nest direction and supply the same delimiter. The result round-trips back to the original shape as long as no field name contained the delimiter.

What delimiter should I use between path segments?+

The default is a dot (user.address.city). Underscores and slashes are also common, especially when downstream consumers can't handle dots in column names. Pick whatever survives your destination format.

Does flattening affect arrays?+

By default arrays stay as arrays. If you want arrays expanded into indexed paths (items.0.name, items.1.name), enable the array-flattening option.

When should I flatten before converting to CSV?+

Always, when the JSON has nested objects you want to inspect column-by-column. Flattening turns nested fields into readable columns instead of stringified blobs.

Common next steps

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}