How to flatten nested JSON into a map of paths

Use TinyToolbox JSON Flattener to inspect nested values, understand escaped keys and array markers, and rebuild the original structure.

Open the tool

A configuration file can put the setting you need four levels below the root. When you review a group of settings together, it is useful to see each complete path next to its value. Flattening JSON gives you that view. A field named enabled becomes easier to identify when the output shows whether it belongs to email notifications or another feature.

TinyToolbox JSON Flattener converts one JSON value into an object keyed by JSON Pointer paths. The output represents nested values without their original indentation. It also keeps markers that distinguish arrays from objects with numeric-looking keys. Use this format to inspect paths, move values into a workflow that understands pointers, or make a round trip through the corresponding unflattener.

Start with a complete JSON value

Copy the object, array, or scalar you want to inspect. If your source is an API response with metadata around the relevant data, decide whether you need the entire response or only one part of it. Flattening a nested section on its own makes paths shorter, but they are then relative to that section. Keep track of the original location so a later reader can find the same values.

For example, suppose a response has settings at the root and notifications inside it. Flattening the whole document can give you /settings/notifications/email. If you instead paste the value of notifications, the same field appears at /email. Either result can be useful as long as you know which root it uses.

The input must be strict JSON. Remove code fences, comments, or explanatory text around it. If the sample fails to parse, JSON Formatter & Viewer can help you inspect its syntax. Keep an original copy if property duplication, precise numeric text, or exact source formatting matters. A parser reads the data values and may collapse duplicate keys or round numbers outside JavaScript’s safe range.

Run the flattener in TinyToolbox

  1. Open JSON Flattener.
  2. Paste the value under Input text.
  3. Select Run tool.
  4. Review the object shown in Result.
  5. Select Copy result if you need to work with the map in another editor or tool.

Processing happens in your browser. The parser supports up to one million characters of input. If the source is too large, extract a complete section rather than copying arbitrary lines from the middle. Flattened output can be longer than the original because each path repeats the names of its ancestor fields. Start with the parts you actually need to review when the result would otherwise be difficult to scan.

Check that the source does not contain information you do not intend to share. A flattened object can make private values easier to find by putting their full paths on single lines. That is useful for inspection and also makes it important to review any excerpt you paste into a shared issue.

Read paths with a short example

Consider this configuration:

{
  "notifications": {
    "email": true,
    "summary": {"day": "Friday"}
  },
  "labels": ["staff", "review"],
  "preferences": {}
}

The result has this shape:

{
  "/notifications/email": true,
  "/notifications/summary/day": "Friday",
  "/labels": [],
  "/labels/0": "staff",
  "/labels/1": "review",
  "/preferences": {}
}

A slash separates each step in a path. In /notifications/summary/day, begin at the root, find notifications, then summary, then day. The result lets you search for the whole path instead of relying on an isolated name. Search for /notifications/ if you want to find descendants of that branch.

Leaf values retain their JSON types. The boolean true is still a boolean, and “Friday” is still a string. An empty object remains {}, as shown for preferences. A scalar input such as true uses the empty string as its path, because that value is already at the root. This differs from /, which points to an object property whose name is the empty string.

Understand the array marker

The “/labels”: [] line in the example is intentional. It marks the value at that path as an array, while the entries at /labels/0 and /labels/1 hold its items. The marker and its child paths belong together. Reading the marker by itself can make a populated array look empty.

Compare these two inputs:

{"values":["first"]}
{"values":{"0":"first"}}

Both can produce a leaf at /values/0. The array version also produces the marker at /values. In the object version, 0 is the property name. In the array version, it is the first index. If you plan to reconstruct the original structure, preserve the marker rather than deleting it as a redundant empty value.

A root array uses an array marker at the empty path. A nested empty array also appears as [], but there will be no descendant entries for it. For a checklist that distinguishes empty collections from missing collections, verify both the marker and whether any item paths follow it.

Decode slashes and tildes in property names

The tool uses JSON Pointer escaping. A slash within a key appears as ~1 in the corresponding path segment. A tilde appears as ~0. For example, the following input has a single root property whose name contains a slash:

{"room/main":{"level~code":"A1"}}

The result contains /room1main/level0code, which points to the value “A1”. The first segment is one name, room/main. Splitting the original key at its literal slash would give the wrong hierarchy. Systems that expect dot-separated paths or bracket notation use different conventions, so confirm what the next step understands before copying the map into it.

A key containing a dot is just a key here. /user.name is one step, while /user/name is two. If your next workflow uses dots to separate steps, a simple search-and-replace can make those paths ambiguous. Convert each path segment deliberately, using the destination’s escaping convention.

Compare or reconstruct a flattened result

To restore nested structure, paste the complete map into JSON Unflattener. Preserve array markers, empty collections, and escaped path segments. Reopen the nested result and check a known field, a populated array, and an empty object. If you removed paths from the map for a focused review, the resulting reconstruction represents that subset and may lack pieces of the source.

Flattening is useful for preparing a list of paths to discuss. For example, a review might ask whether /notifications/summary/day is set or whether /labels/0 has the correct value. Include that path and the relevant value in the review notes. If you need a change report, JSON Difference Checker can compare the original nested values and report added, removed, or changed locations. Array indices are meaningful in either format, so a reorder can affect several paths at once.

If another tool rejects your map, confirm whether it expects a flat object, a list of path and value records, or nested JSON. TinyToolbox produces the first format. Make any additional transformation after checking where markers and empty values should go. A flattened map that looks concise can still have a different shape from what a receiving API expects.

Verify the paths you plan to use

Start with a simple path whose location you already know, then test a key that contains punctuation and a populated array. Check the exact spelling of each path before copying it into code or documentation. If you flattened only a section, record its original location alongside the map. Keep the source JSON when you need to trace numbers, ordering, or duplicate properties later.

Before using the output in an automated process, try a round trip with a representative example and compare the resulting nested values. Add another example with an empty collection or a key containing a slash if those cases are possible. This verifies that the receiving workflow interprets the same path convention and retains the values you intended to carry forward.

Inspect a catalog record with several kinds of paths

Imagine a small catalog record with one item inside an array. The item has a department name stored under a property that contains a slash, and it has an object of display labels keyed by strings that look like numbers. Paste the following sample into JSON Flattener.

{
  "items": [
    {
      "sku": "0042",
      "department/name": "Garden",
      "labels": {"0": "Small"}
    }
  ],
  "notes": null
}

Look for the marker at /items and the entry /items/0/sku. The marker establishes that the first zero in the path is an array index. The value of the SKU is the string "0042", so the leading zeros remain part of the identifier. Next find /items/0/department~1name. The escaped slash belongs inside one property name. A path ending in /department/name would instead describe a nested property under a property called department.

The entry at /items/0/labels/0 also ends in zero, but the source has an object at labels. The result has no array marker for that path. When you reconstruct the complete map, the label belongs to a property named "0" inside an object. The entry at /notes has a null value. If you delete it, the resulting object can lack the property entirely. That change can matter to a program that treats a present null as an explicit empty value.

To test a narrow edit, change only the value on the SKU path in a working copy of the flattened map. Paste the complete edited map into JSON Unflattener. Open the reconstruction and look at the item, department property, label object, and notes. Check that the SKU changed and that the other values and container types still match. Keep the original map for comparison so you can trace an unintended type change back to the edit.

Compare flattened records without relying on entry order

Imagine you receive a revised catalog record with the notes property moved above the items property. A flattened version can present the corresponding paths in a different order even when all of their values match. Compare by path and value if you want to find data changes. A difference in textual order alone may be useful when reviewing formatting, but it does not establish that the SKU or department changed.

Array item order has a different effect. If the source gains a second item and the new item is inserted at the front, the earlier item can move from /items/0 to /items/1. A path comparison reports a change at the original index. If you want to compare the same catalog item across revisions, match using a stable field such as the SKU and then compare its properties. Use index-based comparison when the order itself carries meaning, such as steps in a list of instructions.

Before handing a map to another application, describe the expected path syntax and array-marker convention. Include one short round-trip example that contains an index, a numeric-looking key, and an escaped slash. A receiving tool that agrees on these three cases is easier to check against the actual record. Keep the complete nested source as your reference if a later reviewer needs to check a missing or changed field.