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
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], sotags[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
- Paste or type your JSON into the input box.
- Choose Flatten to collapse it, or Unflatten to expand a flat object back to nested JSON.
- Optionally change the Key delimiter if you prefer
_or/between object keys. - 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.