Skip to main content
Yoryantra
← Back to Tools

JSON Flatten / Unflatten Tool

Flatten JSON into escaped dot/bracket paths, then rebuild the original nested structure.

Objects become escaped property paths and arrays keep explicit [index] segments.

Path convention

Object keys use dots, array positions use brackets, and special characters inside keys are escaped with a backslash.

$.users[0].profile\.name

Output

Processed JSON will appear here.
Parsing and transformation run in your browser. The page does not send the JSON you paste to a processing API.
Path-format caution: escaped dot/bracket paths are a local convention, not a JSON standard. When another system requires a standard pointer syntax, use JSON Pointer (RFC 6901).

A flat path is only useful if it can describe the original shape

Flattened JSON often ends up in spreadsheets, environment-style maps, log pipelines, comparison scripts, or migration code. The difficult part is not turning nested objects into strings; it is keeping enough structure to rebuild them later without guessing.

Array positions therefore use [0], while a numeric object key stays a property such as .0. Dots, brackets, and backslashes that belong to a real key are escaped. That distinction prevents a key named profile.namefrom being mistaken for two nested properties.

Empty objects, root arrays, and awkward key names are preserved

Empty containers

An empty object or array is written as a value at its own path instead of disappearing during recursion. A completely empty root uses the path $.

Root arrays

A top-level array starts with paths such as $[0]and $[1], so unflattening can restore an array rather than inventing object keys named “0” and “1”.

Structural conflicts stop instead of silently overwriting data

Hand-edited flat maps can contradict themselves. For example, $.user cannot be a string while $.user.name also exists, and an object path cannot suddenly continue as an array index. Those cases return an error instead of replacing an earlier value.

Arrays must also rebuild without missing indexes. A map containing only $[2] would otherwise create sparse JavaScript array slots that stringify as nulls, which would not represent the supplied flat data faithfully.

Dot paths and JSON Pointer solve related problems differently

JSON itself defines objects, arrays, strings, numbers, booleans, and null, but it does not define “dot notation” for addressing a nested value. RFC 8259 is the JSON data-format standard; RFC 6901 separately defines JSON Pointer for identifying a value within a JSON document.

Keep that boundary in mind when flattened paths become an API contract. A local convention is fine when both sides agree on it; a public protocol should name and document the exact path syntax it accepts.

Limits worth knowing before flattening very large payloads

  • Input must be valid JSON; JavaScript comments and trailing commas are rejected.
  • Processing stops beyond 25,000 visited values or 120 nested levels to keep the page responsive.
  • Duplicate member names are already resolved by the browser's JSON parser before flattening; interoperable JSON should use unique object names.
  • Flattened output is intended for reversible structure work, not as a canonical JSON serialization or signing format.