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

How to use

  1. Paste a JSON object or array.
  2. Read the dotted keys.
  3. Copy the flat object, or paste it into Unflatten JSON to restore the tree.
  4. Use JSON to CSV if the next step is a table rather than another JSON object.

What is Flatten JSON?

Spreadsheets and some query tools want one row of keys, not a tree. Flatten walks a JSON value and writes a single object whose keys are paths. A nested object uses dots. An array uses bracket indexes. A key that itself contains a dot or a bracket is quoted so the path can be read back.

Read more

{"user":{"name":"Ada","city":"Pune"}} flattens to user.name Ada and user.city Pune. Unflatten of that object returns the original nesting. A path that would collide, such as a key a set to 3 and a key a.b set to 4, is rejected on the way back rather than silently overwritten.

Empty objects and empty arrays are preserved in the path scheme the unflatten step understands. The result is still JSON. It is not CSV. JSON to CSV is the page that turns an array of objects into rows, and it flattens nested fields into dotted column names on its own.

Use cases

  • A developer preparing a nested API object for a sheet with dotted headers.
  • A student learning that user.name is a key, not a lookup that runs by itself.
  • An integrator checking that unflatten restores Ada and Pune.
  • Someone whose document mixes arrays and objects and needs bracket indexes in the keys.
  • A reviewer confirming a conflicting path is rejected instead of merged.

A user object with name and city

{"user":{"name":"Ada","city":"Pune"}}

{ "user.name": "Ada", "user.city": "Pune" }. Unflatten returns the nested user object.

Why use Oddsock

Dot paths and bracket indexes name every leaf, which is the shape a column list and the unflatten step both understand.

Related tools

Using this tool

Keys that contain dots are quoted in the path so unflatten can tell them from nesting.