Skip to content
{ }JSON Formatter

JSON Flatten

Collapse nested JSON into single-level dot-notation keys — for config maps, feature flags, env-var generation and spreadsheet columns.

Input
Output
Paste input and press Flatten.

Nested in, flat out

Flattening turns a deep object into one level of dotted keys: every leaf value gets a path like user.address.city. Arrays contribute numeric segments, so tags: ["a", "b"] becomes tags.0 and tags.1. The data is unchanged — only its shape.

{ "user": { "name": "Ada", "roles": ["admin", "dev"] } }

{
  "user.name": "Ada",
  "user.roles.0": "admin",
  "user.roles.1": "dev"
}

Where flat keys are useful

  • Configuration & feature flags — many systems (Spring, .NET, LaunchDarkly-style) key settings as section.subsection.value.
  • Environment variables — flatten, then upper-case and swap dots for underscores to get USER_ADDRESS_CITY.
  • Spreadsheets & diffs — one key per column, or a flat key/value list that diffs cleanly line by line.
  • i18n / translation files — flat dotted keys are a common message-catalog format.

Reversible

Flattening is lossless: JSON Unflatten rebuilds the original nested structure from the dotted keys, restoring arrays where segments are numeric.

Frequently asked questions

How are arrays represented?

By numeric key segments: {"tags":["a","b"]} flattens to {"tags.0":"a","tags.1":"b"}. Unflatten reads numeric segments back as array indices, so the round-trip restores the array.

What separator is used?

A dot (.), the most common convention. If your own keys already contain dots, unflattening will split on them too — in that rare case a flat form is ambiguous and you should pick a different delimiter in your own tooling.

What happens to empty objects and arrays?

They are preserved as leaves: an empty {} or [] keeps its key with an empty container value, rather than disappearing.

Is the operation lossless?

Yes for standard data — JSON Unflatten reconstructs the original nesting, including arrays. The one caveat is keys that themselves contain dots (see above).