Convert nested JSON to paths and rebuild it
Choose flatten or unflatten and paste the matching input. Review numeric object keys and overlapping paths when rebuilding nested data.
Runs locally in your browser
Choose flatten or unflatten and paste the matching input. Review numeric object keys and overlapping paths when rebuilding nested data.
Runs locally in your browser
Paste a JSON document, choose Flatten or Unflatten and press Run. Flatten turns every leaf into a path such as user.profile.roles.0; Unflatten reads a flat object of paths and rebuilds the nested document. The separator can be a dot or a slash, and a key that contains the separator is escaped with a backslash, so user.profile.roles.0 and a literal “a.b” key stay distinguishable.
Everything runs in the page with browser JavaScript, nothing is uploaded, and the result can be copied or downloaded as kivtools-json-flatten.json or kivtools-json-unflatten.json.
Values are copied without type changes: strings stay strings, numbers stay numbers and null stays null. Keys that look dangerous in JavaScript — __proto__, constructor, prototype — are ordinary data keys here: the tool builds prototype-less objects, so flattening {"__proto__": 1} keeps a “__proto__” path and unflattening it rebuilds the same key.
Empty objects and arrays are kept by default. Turn off “Keep empty objects and arrays” to drop them; the metric then reports how many containers were dropped — 2 for {"keep":{},"drop":[],"value":1}.
Unflatten rebuilds an array only when a node carries exactly the dense numeric keys 0…n-1, which is what a real array looks like after flattening. Sparse paths such as 0 and 2, or a node that mixes 0, 1 and x, stay object keys: no key is dropped and no null hole is invented.
A path that needs the same key in two shapes is reported instead of silently overwritten: the flat object {"a":1,"a.b":2} answers “Path “a.b” conflicts with an earlier key.”, and the previous output is cleared so an old result is never mistaken for the new one.
Flatten walks the document iteratively: a 20,000-level nested value flattens to a single path without a stack overflow. Rebuilding such a document reaches the browser JSON-writer limit, and the tool then shows its localized “too deeply nested” message instead of a raw engine error.
JSON syntax errors keep the engine position detail (for example “line 1 column 9”) after a localized prefix, which is what makes a malformed paste fixable. Downloads are named kivtools-json-flatten.json or kivtools-json-unflatten.json depending on the mode.