Unflatten JSON

Input
Output

Unflatten JSON

Flat key-value data, with keys like customer.address.city, comes from CSV headers, form fields, config stores and search indexes. Unflatten rebuilds the nested JSON: each dot opens an object and a number opens an array.

Example: a row from a spreadsheet export

A record whose keys are paths, as a CSV export or a flat config store gives it. Each dot opens an object and items.0 and items.1 become an array:

Input

{
  "orderId": "ORD-20419",
  "customer.name": "Ananya Rao",
  "customer.address.city": "Pune",
  "customer.address.pin": "411001",
  "items.0.sku": "KB-01",
  "items.0.qty": 1,
  "items.1.sku": "MS-02",
  "items.1.qty": 2
}

Output

{
  "orderId": "ORD-20419",
  "customer": {
    "name": "Ananya Rao",
    "address": {
      "city": "Pune",
      "pin": "411001"
    }
  },
  "items": [
    {
      "sku": "KB-01",
      "qty": 1
    },
    {
      "sku": "MS-02",
      "qty": 2
    }
  ]
}

How do I use the Unflatten JSON?

  1. Paste JSON whose keys are paths, like {"customer.name": "Ananya"}.
  2. Pick the separator your keys use: dot, slash, underscore or double underscore.
  3. Copy the nested JSON.

What does the Unflatten JSON do?

  • Dotted keys become nested objects
  • Number parts become arrays: items.0.sku
  • Separator: . / _ or __

When to use the Unflatten JSON

Flat data with path-like keys comes from many places: CSV and spreadsheet exports, HTML form fields named address.city, config stores and environment variables, search indexes and logging tools. Unflatten turns it back into the nested JSON your code and APIs expect.

Each separator in a key opens a level: customer.address.city becomes {"customer": {"address": {"city": …}}}. A part that's a number makes an array, so items.0.sku and items.1.sku become an items list. Pick the separator your keys use: a dot, a slash, an underscore, or the double underscore of environment-style names like DB__HOST. Flatten, in the same tool, goes the other way.

Frequently asked questions

What if a key has a dot that isn't a level?
Pick a separator that doesn't appear inside your names, such as / or __, and flatten with the same one. A key like "version.major" with the dot separator becomes two levels.
Can I unflatten a whole CSV?
Convert the CSV with CSV to JSON first: it already turns dotted headers into nested objects for every row. Use Unflatten for single objects or JSON that's already flat.
Is my data uploaded?
No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.

More JSON tools

Bracely has 104 JSON tools in one page. Related ones:

Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram