ModernCalcs

JSON Flattener

Flatten deeply nested JSON into dot-notation keys, or unflatten dot-notation keys back into nested objects. Array indices use bracket notation like tags[0].

JSON Input

Flat Output

{
  "user.name": "Alice",
  "user.address.city": "New York",
  "user.address.geo.lat": 40.7128,
  "user.address.geo.lng": -74.006,
  "user.tags[0]": "admin",
  "user.tags[1]": "editor",
  "user.active": true
}

JSON Flattener: Dot-Notation Paths for Nested Data

Deeply nested JSON can be hard to iterate, diff, or store in flat key-value systems. Flattening converts every leaf value to a dot-notation path, making nested data directly addressable. This tool also supports unflattening — reconstructing a nested structure from flat paths.

Frequently Asked Questions

What is dot-notation flattening?

Flattening converts nested keys into a single level using dots as separators. `{"a":{"b":1}}` becomes `{"a.b":1}`. This makes it easy to iterate over all leaf values or use JSON with flat key-value stores.

How are arrays handled?

Array indices use bracket notation: `{"tags":["a","b"]}` becomes `{"tags[0]":"a","tags[1]":"b"}`. Unflatten reverses this back to an array.

When is flattening useful?

Flattening is useful for: storing JSON in flat key-value databases (Redis, DynamoDB single-table), diffing deeply nested structures, form library state management, and creating search index documents.

Can I unflatten a manually edited flat object?

Yes. Switch to Unflatten mode and paste your dot-notation JSON. The tool will reconstruct the nested structure from the key paths.

Does it handle mixed-depth objects?

Yes. Keys at any nesting depth are flattened to their full path. Leaf values (strings, numbers, booleans, null) are preserved at their path.

What happens to arrays of objects?

Arrays of objects are fully flattened: `{"users":[{"name":"Alice"}]}` becomes `{"users[0].name":"Alice"}`. Unflatten reconstructs both the array and the nested objects.