Flatten JSON
Turn a nested JSON object into a flat record of dot notation paths, or do the reverse: paste flat dotted keys such as users.0.name and rebuild the nested structure. Arrays become indexed paths (users.0.role, or users[0].role), leaves keep their JSON types, and keys can be re-nested with unflatten mode. Everything runs on your device with no network.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Flatten turns objects into dotted paths
In flatten direction a nested object is walked depth-first and every leaf becomes a single key built from its ancestor names joined with dots. Objects become simple keys, arrays become indexed paths such as users.0.name, and empty containers are kept as empty objects or arrays rather than dropped. The result is emitted as a pretty-printed JSON object.
Unflatten rebuilds the nesting
Switch to rebuild and paste a flat record of dotted keys. The parser reads both users.0.name and users[0].name forms, distinguishes array indexes from object keys, and reconstructs the nested structure. Contiguous numeric keys collapse back into arrays, so a record flattened with index style round-trips to the original array. Numbers, booleans and null keep their JSON types through the trip.
Choosing the array path style
The Array paths option picks between users.0.name and users[0].name for flatten output. Both styles are accepted in rebuild mode regardless of the setting, and bracket indexes can be mixed freely with dotted names in a single key, which is handy when some of your object keys contain dots of their own.
Conflict and depth limits
If a flattened record tries to put a value and a container at the same path — for example both a.b and a.b.c — unflatten refuses with a clear error instead of silently overwriting one. Deeply nested input is capped at 128 levels, and sorting the flattened keys is available when you want a canonical ordering.
All the work happens on device
Parsing, flattening and rebuilding are plain JSON manipulation in this tab; there is no network call, so the tool works offline and your data never leaves the browser. A 1,000,000-character input ceiling keeps the page responsive on large documents.
Questions
How are arrays flattened?
Arrays become indexed paths: users.0.name. Switch the "Array paths" option to users[0].name if you prefer bracketed notation.
Can I get back to a nested object?
Yes — switch the direction to "Rebuild dotted". Paste a flat record and it is nested again, and types keep through the round trip.
What if dotted output and nested output conflict?
If a key is both a value and a container (a.b alongside a.b.c) unflatten refuses with a conflict error instead of guessing.
Does it preserve numbers, booleans and null?
Yes. Leaves are kept with their JSON types, and unflatten parses them back the same way they were given.
Related tools
See categoryJSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
JSON to Python Dataclasses
Generate Python dataclass or TypedDict definitions from a JSON sample, with nested models.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
Properties Converter
Convert Java .properties config to JSON or serialize JSON back to .properties.