Turn nested JSON into a flat set of dot-notation keys, or turn flat keys back into nested JSON. Both directions are here because you need both: flattened keys are how environment variables, spreadsheet columns, form field names and many config formats express nesting, so going back is as common a task as going forward. Array indices can be written as `a.0` or `a[0]`, and the separator is yours to change. The thing this gets right that many flatteners do not is round-tripping — empty objects and arrays are preserved rather than silently vanishing, and null is kept as the value it is. Drop those and the result cannot be reversed, which quietly defeats the point. Everything happens in your browser.
| Input | Flattened |
|---|---|
| {"a":{"b":1}} | {"a.b": 1} |
| {"a":[1,2]} | {"a.0": 1, "a.1": 2} |
| {"a":[{"b":1}]} | {"a.0.b": 1} |
| {"a":{}} | {"a": {}} — kept, so it round-trips |
| {"a":null} | {"a": null} — null is a value |
| [1,2] | {"0": 1, "1": 2} |
No. Everything runs in your browser and nothing is transmitted.
Yes — switch on 'Unflatten instead' and paste the flat keys. The two directions round-trip exactly, including empty objects and arrays, which many flatteners drop and thereby make the operation one-way.
Because an empty object has no leaf inside it, so a naive flattener emits nothing for it and the key disappears. Unflatten that result and the key is simply gone — a silent change to your data. Keeping them as values avoids that.
Depends on the consumer. Bracket notation is what most form libraries and many config systems expect; dot notation is simpler and common in flat key-value stores. Both round-trip here.
Change the separator to something that does not appear in your keys — a pipe or a double colon, for instance. Otherwise unflattening will split in the wrong place, because it cannot tell your dot from a level boundary.
Flattening walks the document and joins the keys along each route into a single dot-notation key, with array indices becoming either `a.0` or `a[0]` depending on the notation chosen, since config systems and form libraries disagree about which they expect. The detail most flatteners get wrong is empty containers: an empty object or array has no leaf beneath it, so a naive recursion emits nothing and the key disappears entirely. That makes the operation irreversible, and a flattener you cannot reverse is of limited use — so empty objects and arrays are kept as values in their own right. Null is likewise preserved rather than skipped, because null is a value and its absence means something different. Unflattening splits each key back into segments and decides array versus object by looking at the NEXT segment: a run of digits creates an array, anything else an object, which is exactly the convention flattening writes and is what makes the pair round-trip. The top level is returned as an array when every root key is an index, so a flattened array comes back as an array rather than as an object with numeric keys. Both directions are available in one place because the reverse is needed as often as the forward: flattened keys are how environment variables, spreadsheet columns and form field names represent nesting, and turning those back into real JSON is the other half of the job. Everything runs in your browser.