Cryonel

JSON Flatten / Unflatten

Flatten deeply nested JSON into single-level dot-path keys (handy for spreadsheets or env-style config), or rebuild nested JSON from flat keys.

How to use it

Paste nested JSON and click Flatten to get dot-path keys like "a.b": 1 (array indexes become path segments too, e.g. "a.c.0": 10). Paste flat keys and click Unflatten to rebuild the nested structure — numeric path segments are rebuilt as arrays.

When flat JSON is useful

Nested JSON is natural for APIs, but some destinations expect one value per field. A spreadsheet column, environment-style configuration table, log index, form state, or key-value store may be easier to inspect when each leaf has a complete path. Flattening converts structure into addressable keys without changing string, number, boolean, or null leaf values. It is also useful when comparing where two large payloads differ: a reviewer can scan paths instead of repeatedly opening nested objects.

Flattening example

For an input such as {"user":{"name":"Ada","roles":["admin","editor"]}}, this tool produces {"user.name":"Ada","user.roles.0":"admin","user.roles.1":"editor"}. Object keys and array indexes become dot-separated path segments. Unflattening that result recreates the object and the ordered roles array. The conversion runs entirely in this tab, so copied API responses are not uploaded to Cryonel.

Understand path ambiguity

A flat representation needs a separator, and this tool uses a literal dot. That creates an unavoidable ambiguity when an original key already contains a dot. For example, the original key "user.name" and the nested path user → name both become user.name. Rename or escape such keys in your own data contract before depending on a round trip. The same warning applies when separate flat keys require incompatible containers, such as items.name and items.0: one path describes an object while the other describes an array.

Arrays, empty containers, and numeric keys

Array indexes are preserved as numeric path segments, and unflattening creates an array when the next segment is numeric. This is practical for ordinary API arrays, but an object whose property name is literally "0" can therefore be interpreted as an array position during reconstruction. Empty objects and arrays have no leaf values, so the tool records the empty container at its current path. Sparse array paths can create empty positions; check the rebuilt result before using it as an update payload.

Use the result safely

Validate the source first if it came from an API, log, or user-controlled file. Flattening does not validate a business schema, resolve references, or make untrusted keys safe for a database query. Do not concatenate generated paths into SQL, shell commands, document-store operators, or object mutation code without applying the destination's own validation rules. After unflattening, compare the rebuilt document with the original using JSON Diff when an exact round trip matters. For exploration without changing the shape, use JSON Tree Viewer; for selecting a subset, use JSONPath Tester.

Frequently Asked Questions

What happens to empty objects or arrays?

An empty object or array has no leaf keys to flatten, so it's kept as-is at its own path.

Does flatten → unflatten always round-trip?

Yes, for standard JSON keys. Keys that already contain a literal dot will be ambiguous when unflattened, since dots are used as the path separator.

What if an original key contains a dot?

It becomes ambiguous with a nested path. Rename or escape those keys in your own contract before relying on an exact round trip.

Related Tools