JSON Flatten & Unflatten
Flatten JSON with escaped pointer paths and explicit container types. Restore arrays, numeric object keys and empty containers without ambiguity.
How to use
The output contains $format, containers and values. containers records object or array for each JSON Pointer path; values stores scalar leaves. This explicit envelope prevents a numeric object key from being mistaken for an array index.
An empty path means the root. Slashes and tildes in keys use ~1 and ~0. Empty objects and arrays remain container entries even when they have no leaves. Original number tokens are retained in both directions.
Behavior and limits
Unflatten expects json-pointer-flat/v1 output from this tool, not arbitrary dot-separated maps. Missing parents, conflicting paths and sparse arrays are errors. Limits: 64 levels, 20,000 nodes and 200,000 input/result characters.
Questions & answers
Will dots in a key create nested objects?
No. Dots are ordinary key characters; only the declared JSON Pointer structure defines nesting.
Is my input sent to a server?
No. Processing runs in your browser and input is not submitted to an API. Original files and remote databases are not modified.
Other Languages
References
How we make sure
We check this tool with the automated test suites linked below. Example checks are shown in their original language.
- Verification method
- Flatten/unflatten data and check numeric object keys, arrays, escaped paths and empty containers.
- Comparison reference
- Original JSON structure and expected paths; structural and round-trip checks.
- Verification scope
- These samples and boundaries do not prove correctness for every input.
Test source and cases (select a file to read it)
-
data-tools.test.js
- flattened JSON restores numeric object keys, arrays, escaped paths and empty containers
These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.