Skip to main content

JSON Flattener

Flatten nested JSON into a single-level object with dot-and-bracket path keys (user.roles[0]), or unflatten flat keys back into nested JSON. Pick the key delimiter and get pretty-printed output.

Input

Joins nested object keys. Array indices always use [N].

Output

Result
 
Was this helpful?

Guides

JSON Flattener turns a deeply nested JSON object or array into a single-level object whose keys are readable path strings — and turns those flat keys back into nested JSON again. Paste your data, pick a mode, and copy the pretty-printed result.

What it does

Nested JSON is awkward for spreadsheets, .env-style config, form fields, and log pipelines that expect flat key–value pairs. Flattening rewrites a structure like {"user":{"roles":["admin","dev"]}} into:

{
  "user.roles[0]": "admin",
  "user.roles[1]": "dev"
}

Every value in the output is a leaf from the original document, keyed by the full path used to reach it. Unflattening reverses the process, reconstructing the original objects and arrays from those path keys.

Key-path convention

  • Object keys are joined with the delimiter you choose — a dot (.) by default, or an underscore (_) or slash (/).
  • Array indices always use bracket notation [N], so tags[0] is unambiguous even when a delimiter appears inside a key.

This mixed dot-and-bracket style is the most widely recognised flat-key format (the same one used by many form libraries and lodash-style path helpers), which makes the output easy to read and reliable to reverse.

How to use it

  1. Paste or type your JSON into the input box.
  2. Choose Flatten to collapse it, or Unflatten to expand a flat object back to nested JSON.
  3. Optionally change the Key delimiter if you prefer _ or / between object keys.
  4. Copy or download the formatted result — it updates as you type.

Flatten

Recursively walks the parsed JSON and emits one entry per leaf value (string, number, boolean, or null). The result is itself valid JSON, pretty-printed with two-space indentation.

Unflatten

Splits each key on the delimiter and bracketed indices, then rebuilds nested objects and arrays. A round-trip — flatten then unflatten with the same delimiter — returns your original structure.

Try an example

Use the built-in examples to see a nested object flattened, a nested array flattened, and a flat object expanded back into nested JSON.

FAQ

Does it change my numbers or booleans?

No. Leaf values are preserved exactly; only the key structure changes. Empty objects and arrays are kept as leaf values.

Which delimiter should I pick?

Use the dot if you're unsure — it's the default and the most common. Choose underscore or slash when your target system reserves dots or expects path-style keys.

Is my data uploaded anywhere?

No. Flattening and unflattening run entirely in your browser. Nothing you paste is sent to a server, so it's safe for private or sensitive JSON.

jsonflattenunflattendot-notationdeveloper

Part of a workflow

All collections

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.