DevKits

JSON Flatten / Unflatten — Dot Notation Converter

Flatten nested JSON to a single-level 'path → value' map (dot / bracket notation), or unflatten a flat map back into nested JSON. Compatible with lodash and Spring conventions. 100% local.

Last updated:

176 chars · 12 lines
{
"user.id":42
"user.name":"Alice"
"user.roles[0]":"admin"
"user.roles[1]":"editor"
"user.address.city":"Beijing"
"user.address.zip":"100000"
"active":true
}

Paste nested JSON to get a flat map of dot / bracket paths to values, or paste a flat map to reconstruct the nested structure. Round-trips losslessly with either bracket (a[0].b) or dot (a.0.b) array notation.

What is JSON Flatten?

A flat JSON representation collapses every nested object and array into a single-level map where each key is the full path (like `user.address.city` or `items[0].name`) and each value is the leaf. It's the natural format for exporting JSON to spreadsheets, storing settings in a key/value backend (Vault, Redis, Spring @ConfigurationProperties), diffing two JSON documents by field, and feeding search engines that don't support nested queries. This tool converts in both directions and supports the two industry-standard array notations: bracket (Postman / JSONPath) and dot (lodash / Spring).

How to flatten and unflatten JSON

  1. 1Choose direction — Flatten (nested → flat) or Unflatten (flat → nested).
  2. 2Choose an array style: bracket (a[0].b) for JSONPath / Postman compatibility, or dot (a.0.b) for lodash / Spring.
  3. 3Paste your JSON. The output pane instantly renders the converted form.
  4. 4Copy the result. Keys containing the delimiter character are auto-wrapped in backticks so round-tripping stays lossless.

Tips & Best Practices

  • For CSV export, flatten first — one column per path — so every row is a rectangular record.
  • When your target is Spring @Value / configuration properties, choose dot-array style and switch the delimiter to match the framework's expectation (usually '.').
  • Empty objects and arrays are encoded as {} and [] sentinel keys so structure survives the round trip — don't strip them if you plan to unflatten.

Frequently Asked Questions

What array formats are supported?

Two conventions: bracket (a[0].b — used by Postman, JSONPath) and dot (a.0.b — used by lodash's _.get / _.set and Spring configuration). You can round-trip in either — pick the one your consumer expects.

Is flatten → unflatten lossless?

Yes for typical JSON. Empty objects and arrays are preserved via {} / [] sentinels in the flat map so structure is retained. Keys that themselves contain the delimiter are wrapped in backticks (`) to disambiguate.

Why would I need a flat JSON representation?

Exporting to spreadsheets (each row = one field), building a config store keyed by dot-path, diffing two JSON documents at the field level, and feeding into search indexes that don't support nested queries.

What if a key contains a dot?

The tool wraps such keys in backticks (e.g. `my.key.with.dots`) in the flat output so unflatten can round-trip correctly. If your keys frequently contain dots, switch the delimiter to / or __ in the toolbar for cleaner paths.

Is my JSON uploaded anywhere?

No. All processing happens locally in your browser as client-side JavaScript.

Related Tools