FormatterHQ

JSON Unflatten: Dot Notation to Nested JSON

Paste a flat JSON object with path-style keys such as order.items.0.sku and get the nested structure back. Works with dots, brackets or any separator you choose.

Input JSON
Output JSON
Ready.

How to use the JSON Unflatten

  1. Paste a flat JSON object whose keys are paths, for example {"a.b": 1}.
  2. Enter the Key separator your keys use (a dot by default).
  3. Choose whether Numeric keys become arrays or stay object keys.
  4. Click Unflatten and copy the nested JSON.

Rebuild nested data with JSON unflatten

JSON unflatten is the reverse of flattening. It takes an object whose keys are paths, such as "order.customer.name", splits each key on the separator and writes the value into a nested structure. It is the quickest way to turn a flat export, a translation file or a key-value dump back into readable JSON.

Example

Input:

{
  "order.id": 1001,
  "order.items.0.sku": "MUG-01",
  "order.items.1.sku": "CAP-02"
}

Output:

{
  "order": {
    "id": 1001,
    "items": [
      { "sku": "MUG-01" },
      { "sku": "CAP-02" }
    ]
  }
}

Bracket indexes work too: "user.tags[0]": "admin" and "user.tags[1]": "beta" produce "tags": ["admin", "beta"], so output from JSON flatten in either array style can be pasted straight back.

Options explained

  • Key separator: the string that splits a key into segments. Set it to __ to expand {"db__host": "localhost", "db__port": 5432} into {"db": {"host": "localhost", "port": 5432}}.
  • Numeric keys: Become arrays (default) turns segments like 0 and 1 into array positions.
  • Numeric keys: Stay object keys keeps them as strings. Use this when numbers are identifiers, not positions.
  • Indent: 2 spaces, 4 spaces or tabs.

Edge cases

Numbers that are really IDs

With the default setting, {"http.ports.80": "web", "http.ports.443": "tls"} creates an array with 444 slots, 442 of them null. Switch Numeric keys to Stay object keys and you get the intended {"http": {"ports": {"80": "web", "443": "tls"}}}. The same applies to HTTP status codes, years and database IDs.

Conflicting keys

If the input has both "a": 1 and "a.b": 2, the scalar is replaced by an object when the deeper key is processed, because a cannot be a number and an object at once. Keys are applied in the order they appear.

Input must be a flat object

Arrays and bare values are rejected with a clear message. Values themselves can be anything, including nested objects, which are copied as they are.

Unflatten vs. other tools

Unflatten works on JSON input. If your dotted keys live in a Spring application.properties file, use Properties to JSON, which parses the file format and nests keys in one step. For environment variables joined with __, the .env to JSON converter has a nesting option.

Where flat JSON comes from

  • Translation files. Tools for i18n often store keys like "nav.home.title". Unflatten them when a library expects nested objects.
  • Spreadsheet exports. Column headers such as address.city turn into flat keys after CSV to JSON; unflatten each record to get nested objects back.
  • HTML forms. Fields named shipping.street or items[0].qty are serialized as flat pairs, and unflattening shows the intended structure.
  • Logs and analytics. Many logging pipelines flatten events so each path becomes a searchable field.

Privacy

Everything runs locally in your browser; the JSON you paste is not uploaded.

Frequently asked questions

How do I convert dot notation keys to nested JSON?
Paste the flat object, keep the separator as a dot and click Unflatten. Each key is split on the dots and the value is written at that path.
Why did my output get lots of null values?
Numeric segments are treated as array indexes by default, so a key like ports.443 creates an array long enough to hold index 443. Set Numeric keys to Stay object keys to keep them as ordinary property names.
Does it understand keys like items[0].name?
Yes. Bracket indexes are recognized in any segment and always produce array positions, so flattened output in bracket style converts back correctly.
Can I use a separator other than a dot?
Yes. Enter any string in Key separator, such as _, __, / or :. It is matched literally, so characters like . or | do not need escaping.
Can I unflatten a list of flat records at once?
The input must be a single flat object. For an array of records, wrap each record with a numeric prefix, such as 0.name and 1.name, and the default Numeric keys setting rebuilds them as an array of objects.

Last updated September 26, 2026

Related tools

JSON Validator Validate JSON online and find syntax errors fast. Get the exact line and column of each problem and fix broken JSON in one click. JSON Viewer & Beautifier View JSON as a collapsible tree and beautify it at the same time. Explore nested objects and arrays without losing your place. JSON5 Formatter Format and beautify JSON5 with comments, unquoted keys and trailing commas, or convert JSON5 to strict JSON. JSON5 Validator Validate JSON5 syntax online. Check config files with comments and trailing commas and get line and column for each error. JSONL to JSON Converter Convert JSON Lines (JSONL / NDJSON) into a formatted JSON array. Invalid lines are reported with their line number. JSONPath Tester Test JSONPath expressions online against your JSON. Supports filters, wildcards, recursive descent and slices, returning values or paths. String to JSON Converter Convert an escaped JSON string back into formatted JSON. Handles quoted literals, backslash-escaped text and double-encoded JSON. JSON Graph Visualizer Visualize JSON data as a graph of connected nodes. See objects, arrays and values as a diagram of linked boxes with size badges. jq Playground Run jq filters on JSON in your browser with real jq 1.8: live output, -r -c -s -n -S and --arg options, clear errors and a clickable cheat sheet. JSON Cleaner Clean JSON by removing null values, empty strings, empty arrays and empty objects at any depth. Optionally trim whitespace in strings. JSON Decode Online Decode JSON strings online. Convert escaped or encoded JSON text into readable, formatted JSON, similar to json_decode. JSON Deserialize Online Deserialize an escaped JSON payload into formatted JSON, then map it to typed objects in JavaScript, Python, Java or C# safely.