Skip to content
OddsockLocal
Local
Source text
{
  "color": "red",
  "count": 2
}
1 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste an object of path keys into Source text.
  2. Use dots for object keys and [0], [1], and so on for array indexes.
  3. Read the nested, pretty-printed value.
  4. If the message names a conflicting path, remove the key that collides and paste again.

What is Unflatten JSON?

Unflatten JSON reads an object whose keys are paths and builds the nesting those paths describe. Dots open objects. Bracketed numbers open arrays. item.name and item.qty become an item object. tags[0] and tags[1] become a tags array. The result is pretty-printed.

Read more

A flat object whose keys contain neither dots nor brackets is already the structure, so {"color":"red","count":2} comes back unchanged. Conflicting paths are refused: a key that is both a leaf and a parent, a mix of array and object at the same step, or a duplicate path. An empty-string key is the root itself, and it is allowed only when it is the only key.

Use cases

  • A sheet of path keys from Flatten JSON is turned back into the nested item a client expects.
  • A config stored as item.name and item.qty is rebuilt before it is saved as JSON.
  • tags[0] and tags[1] are rebuilt as an array in index order before the payload is saved.
  • A flat color object is run through unflatten to confirm it has no hidden paths.
  • A bad export that reused a path as both a value and a parent is caught by the conflict error.

Paths back into an item

For a rebuild, paste {"item.name":"Pen","item.qty":4,"tags[0]":"red","tags[1]":"blue"}. The sample {"color":"red","count":2} has no dots.

The path object returns item with name Pen and qty 4, plus tags as ["red", "blue"]. The sample returns { "color": "red", "count": 2 }.

Why use Oddsock

The paths flatten produced are enough to rebuild the objects and arrays, so the flat form is a real encoding and not a one-way loss.

Related tools

Using this tool

Those keys are single segments. Unflatten nests only keys that contain a dot or a bracket index.