Zero Signup ToolsFree browser tools

Developer Tools

JSON Flatten Unflatten

Flatten nested JSON into dot-path keys, or unflatten dot-path keys back into nested JSON. Dot, bracket, and PHP/Rails notations supported.

Mode

Path notation

Example: address.city, items.0.sku

Used between key segments. Default is a single dot.

Options

Stops recursion at this depth. Empty means no limit.

How to use

  1. Pick Flatten to turn a nested JSON object or array into a flat path-keyed map, or Unflatten to do the reverse.
  2. Paste your JSON into the input area on the left. Click Load sample for a worked example, or type your own object or array literal.
  3. Choose the path notation: Dot (Lodash, MongoDB, i18n), Mixed bracket (jq, JSONPath, JavaScript), or All brackets (Rails, PHP, qs form encoding).
  4. Set the separator if you need something other than a single dot, or set a Max depth to do a partial flatten that keeps deep sub-trees inline.
  5. For Unflatten, leave Detect arrays from numeric keys on to rebuild arrays from 0, 1, 2 sequences, or turn it off to keep every key as a string property.
  6. Click Copy to copy the result, or click Use output to round-trip the value back through the opposite mode for a quick sanity check.

About this tool

JSON Flatten Unflatten is a two-way converter between nested JSON and a single-level flat object keyed by path strings. Paste any JSON value and pick a mode: Flatten walks the structure and emits one key per leaf, where each key is the path that gets you to that leaf (for example user.address.city or items.0.sku); Unflatten reads a flat object whose keys are paths and rebuilds the nested object or array structure that produced it. Three path notations are supported so the same tool covers the conventions used across the ecosystem. Dot notation (a.b.0.c) is the default and matches Lodash _.get, MongoDB dot-paths, and most i18n message catalogs. Mixed bracket notation (a.b[0].c) is the form used by jq, JSONPath, JMESPath, and most JavaScript developers when they want to make array indices visually distinct from object keys. All-brackets notation (a[b][0][c]) is the form used by HTML form encoding, Rails strong parameters, PHP $_POST, and the qs and form-data URL encoders, so this is the right pick when you need to round-trip a payload between a JSON object and a form-style URL. The separator character is configurable for dot and mixed-bracket notations, so you can use slashes, double colons, or any other delimiter when your keys contain dots. Flatten also exposes options that matter in real codebases: Keep empty objects and arrays preserves empty {} and [] as leaf values so a round-trip is structurally identical (the default behaviour of the popular flat npm package), Sort keys alphabetically gives you stable A to Z output ideal for diffs and snapshot tests, Warn on separator inside keys surfaces ambiguous paths that would not round-trip with the chosen notation, and Max depth lets you stop recursion at a chosen level and keep deeper sub-trees inline as a single value (handy when you want a partial flatten for telemetry, logs, or change-detection). Unflatten reverses the operation safely: it parses each key into segments with the same notation, builds the nested structure, and uses the standard convention to decide between arrays and objects (a container whose keys are exactly 0, 1, ..., n-1 becomes a JS array, anything else becomes an object). Array detection can be turned off if you want every numeric key kept as a string property, which is what some i18n loaders and PostgreSQL jsonb columns expect. The tool reports the number of leaf entries produced by Flatten and the number of keys consumed by Unflatten so you can sanity-check the round-trip. Parsing and emission run entirely in your browser via the native JSON parser. The data you paste here, including any IDs, secrets, or PII, never leaves your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools