Flattening trades nested structure for a single object whose keys describe paths to values. It can make deeply nested data easier to scan or map, but path strings are a representation—not a universal table format. MyJSONPal's JSON Flatten tool andJSON Unflatten tool run locally and use the same configurable separator so the shape can be restored.
What flattening changes
Starting document:
{
"user": { "profile": { "name": "Ari" } },
"scores": [98, 91]
}With the default dot separator, nested leaves become path keys:
{
"user.profile.name": "Ari",
"scores.0": 98,
"scores.1": 91
}Object keys become path segments and array indexes become numeric segments. Primitive leaf values remain values. Nested empty objects and arrays are kept as values rather than disappearing.
Escaping keeps path keys unambiguous
A key can itself contain the selected separator. With a dot separator, a key namedaccount.name must not be mistaken for two nested keys. The flattener escapes separator characters with a backslash; it also escapes numeric object keys so they remain distinct from array indexes. Empty path segments have an escape representation too.
Use the same separator when unflattening, and do not remove escape characters from the path keys. If your original property names contain dots, choose a different separator before flattening or let the tool escape those dots.
Rebuild the nested document
Unflattening reads each path segment and creates objects or arrays as required. Unescaped numeric segments indicate array indexes; escaped numeric keys remain object properties. For example, scores.0 and scores.1 reconstruct an array underscores.
The tool reports conflicts instead of silently overwriting them—for example, when one path assigns a value to user while another tries to create user.name, or when a path level mixes array indexes and object keys. Missing array indexes serialize asnull entries, so keep paths complete if array positions matter.
A safe round-trip workflow
- Keep an unchanged copy of the original JSON.
- Flatten the object or array using a separator that fits your key names.
- Preserve the escaped path keys while editing or transferring values.
- Unflatten using the same separator and resolve any reported path conflicts.
- Compare the reconstructed JSON with the original if the round trip must preserve every detail.
For querying selected values rather than transforming the document, useJSONPath. For a spreadsheet with explicit columns, first reshape the data into records, then use JSON to CSV.