Trexmi
Converter Ready

JSON Unflatten

Rebuild nested JSON objects and arrays from a reversible $-rooted flat path map with collision checks, escaped property names, and strict contiguous array indexes.

Reconstruct objects from dot or slash paths Create arrays from bracket indexes Restore escaped property names Preserve typed leaf values and empty containers
Conflicting paths, mixed object/array containers, and sparse array indexes are rejected instead of being silently overwritten.
INPUT Flattened JSON path map *
0 chars0 words0 lines
Paste an object produced by JSON Flatten. Paths must start with $, object segments use the selected separator, and arrays use [index]. Example: Trexmi developer sample

Tool settings

Ctrl / ⌘ + Enter
Reconstructed nested JSON Inspect the restored object/array tree and copy the validated JSON.
About the tool

What JSON Unflatten does

JSON Unflatten reverses the path map generated by Trexmi JSON Flatten. A path begins with $, uses a dot or slash for object properties, and uses brackets for array indexes. The values in the flat object become leaves in the reconstructed tree.

The processor refuses ambiguous input instead of silently replacing data. A property cannot be both a scalar leaf and the parent of another path. Object properties cannot conflict with array indexes, and an array must contain every index from zero without gaps. Empty objects and arrays can be restored directly from leaf values.

JSON Unflatten rebuilding a nested object and array tree from flat paths
Reconstruct nested JSON while detecting path collisions before data is overwritten.

How to use

  1. Paste the flat map. The outer document must be a JSON object, not an array.
  2. Match the separator. Select dot for paths such as $.user.name or slash for $/user/name.
  3. Run JSON Unflatten. The tool parses escaped property segments and array indexes.
  4. Resolve errors. Fix ancestor conflicts, object-versus-array conflicts, invalid indexes, or missing array positions.
  5. Verify the result. Compare it with the expected schema and use JSON Validator before production import.
Built for the task

Why use JSON Unflatten?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Nested structure restored

Turn explicit paths back into objects and contiguous arrays with original scalar types.

02

Collision protection

Stop when one path would overwrite another path or change a container type.

03

Escaped keys decoded

Restore property names that contain separators, brackets, or backslashes.

04

Valid JSON output

Serialize the completed tree as readable JSON only after all paths pass structural checks.

Useful answers

Questions about JSON Unflatten

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 What input does JSON Unflatten require?

The input must be a JSON object whose property names follow the Trexmi $-rooted flat-path grammar and whose property values are the leaves to restore.

02 Must I use the same separator as JSON Flatten?

Yes. Selecting slash for dot paths or dot for slash paths changes how object-property boundaries are parsed.

03 How does JSON Unflatten know an array from an object?

Bracket tokens such as [0] create arrays. Separator-prefixed segments such as .0 create object properties, even when the property name contains digits.

04 Why are sparse arrays rejected?

JSON arrays are ordered sequences. Rejecting a map that begins at index 2 avoids silently adding null values or serializing the structure as an object.

05 Can a flat map contain only the $ path?

Yes. This is how a root scalar, null, empty array, or empty object is represented. The root path cannot be combined with child paths.

06 What is a path collision?

A collision occurs when one path is an ancestor of another leaf or when the same container must be both an object and an array. The operation stops before overwriting either value.

07 Is the path syntax JSON Pointer?

No. Trexmi uses its own reversible dot-or-slash grammar with bracketed array indexes. JSON Pointer uses a different slash syntax and different escaping rules.

08 Does successful reconstruction prove the data is valid for my API?

No. The result is syntactically valid JSON, but required fields, value formats, allowed enums, and business rules still need schema or application validation.

Learn JSON

Read the complete JSON Guide

Learn JSON objects, arrays, value types, validation, formatting, parsing, API workflows, and common syntax errors.

  • Objects, arrays, and values
  • Validation and formatting
  • API and parsing workflows
Read guide Practical explanations and examples

Examples

Rebuild a customer object

All paths share the same object parent and scalar types remain intact.

Input
{"$.customer.id":42,"$.customer.name":"Lin","$.customer.active":true}
Output
{"customer":{"id":42,"name":"Lin","active":true}}

Rebuild an array

Contiguous zero-based indexes become a JSON array in the specified order.

Input
{"$.tags[0]":"json","$.tags[1]":"tools","$.tags[2]":"api"}
Output
{"tags":["json","tools","api"]}

Restore an escaped key

The doubled JSON backslash decodes to one path escape, so the first dot belongs to the property name.

Input
{"$.release\\.version.major":2}
Output
{"release.version":{"major":2}}

Reject an ancestor conflict

The same location cannot be both a string and an object containing another property.

Input
{"$.user":"Ada","$.user.name":"Ada Lovelace"}
Output
Error: Path conflict: an existing leaf is also an ancestor of $.user.name.

Reading $-rooted paths

Every path starts at $. The selected separator introduces an object property, and [number] introduces an array position. A backslash escapes the next character inside a property segment. The parser requires the complete path to follow this grammar; unexpected text after a root, property, or array index is reported as an error.

The safest source is output copied directly from JSON Flatten. Hand-written maps are supported, but escaping and separator choices must be consistent.

Why conflicting paths are blocked

Consider $.account with the value false and $.account.id with the value 7. Reconstructing both would require replacing the boolean with an object. Older unflatten implementations often do this silently. Trexmi detects ancestor, descendant, and container-type conflicts before returning output.

When a conflict appears, decide which source field is authoritative. Renaming paths or changing a scalar to an object is a data-model decision, not a formatting fix.

Contiguous array indexes

An array must begin at index zero and continue without gaps. A map containing [0] and [2] but no [1] is rejected. This avoids inventing a missing value. If the numeric labels are identifiers rather than positions, encode them as object properties using the selected separator.

Use JSON Pointer Tester to resolve a standardized pointer against the reconstructed output, and JSON Formatter to inspect the final document.

Limitations and validation

The tool does not infer a business schema, merge duplicate records, coerce dates, normalize numbers, or verify that a path map came from the same version of another application. Duplicate property names already collapsed by a JSON parser cannot be recovered. Input size, depth, and array-index limits protect the server from pathological documents.

Review JSON RFC 8259 for JSON syntax and interoperability. Review JSON Pointer RFC 6901 when another system explicitly requires standard pointer syntax instead of this flat-map convention.

Final checks

Run the reconstructed document through JSON Validator, then validate it against the receiving API or database schema.