On this page
You can find a value in nested JSON by opening objects and arrays until you reach it. Let’s find the second item’s product code in an order and copy its path. The sample also includes a property named order.items, so we can see how that differs from items inside order.
Find the second item in an order
Copy this complete document into the JSON Tree Viewer:
{
"order": {
"items": [
{"sku": "L-10", "price": 12},
{"sku": "L-11", "price": 18}
],
"shipping": null
},
"order.items": {"sku": "LITERAL"},
"items[0]": "LABEL",
"extras": []
}
The outer object is the document’s root. Inside order, the items array holds two items. Array indexes start at 0, so the second item is at index 1. Its sku is "L-11".
Objects group properties by name, while arrays hold an ordered sequence of values, as RFC 8259 explains. For a refresher on value types, read the introduction to JSON.
Follow the path in the viewer
- Paste the document into JSON input and select Explore JSON. Pasting alone does not start parsing.
- The tree initially shows the root, whose path is
$. Click the + sign on that row to expand it, then do the same for theorderproperty. - Expand
items. Elements with indexes0and1appear. Expand the element at index1. - Select its
skurow. Check that its type is string and its preview displays"L-11". - The selected path is
$.order.items[1].sku. Select Copy selected path to share that location.
To close a branch, click its − sign. If you prefer the keyboard, use the right arrow to expand a branch and the left arrow to collapse it.
For this sample, JSON values shows 14: the count includes the root, containers, and their values. Visible rows starts at 1 and changes as you expand, collapse, or switch pages. It is not the document’s total value count.
Tell paths apart from literal property names
These sequences lead to different locations in the same example:
| Steps | Path displayed by the viewer | Result |
|---|---|---|
order → items → index 1 → sku |
$.order.items[1].sku |
"L-11" |
Root property order.items → sku |
$["order.items"].sku |
"LITERAL" |
Root property items[0] |
$["items[0]"] |
"LABEL" |
order → shipping |
$.order.shipping |
null: the property exists. |
order → discount |
No row or selectable path exists. | The property is absent. |
extras |
$.extras |
[]: an array with no elements. |
There are several sku fields, so copy the full path when sharing one. Notice the last three rows, too: shipping exists and is null, discount is missing, and extras is an empty array. That means there is no extras[0] element to open.
Read and share the copied path
The viewer uses $ for the root, dots for simple property names, and brackets for array indexes. Special names appear in brackets as a double quoted string. Quotes and backslashes within a name are escaped as they would be in a JSON string:
| Literal name of a root property | Displayed path |
|---|---|
a.b |
$["a.b"] |
a"b |
$["a\"b"] |
a\b |
$["a\\b"] |
a/b |
$["a/b"] |
The slash / is preserved; it does not separate levels in this notation. Copy the whole path instead of rebuilding it without quotes or escapes. If the root were the array [{"sku":"L-10"},{"sku":"L-11"}], the second code would have the path $[1].sku. If the entire document were null, its path would be $.
The copied path gives someone reviewing the same JSON a location to refer to. The viewer uses its own notation, which differs from JSON Pointer. To use the path in another tool, check which syntax that tool accepts.
If you’ve already parsed the sample into a JavaScript object called data, here’s how to access the two sku fields:
data["order"]["items"][1]["sku"] // "L-11"
data["order.items"]["sku"] // "LITERAL"
What to check when a value is not visible
| What you see | What to check or do |
|---|---|
You reach "L-10" |
You chose index 0. The second item is at index 1. |
| You see only an object or array | If it has elements, click +. A collapsed branch hides rows. |
You cannot see discount inside order |
Check the correct object and all its pages. This sample has no such property. |
You see null or a container marked as having no children |
These are present values; null and empty containers have no children to expand. |
| Some list elements are not visible | Each page holds up to 50 rows. Use Next page or Previous page. |
| A limit warning appears | Read the diagnostic. For the 500 visible row limit, collapse another branch; for input or parsing limits, reduce the document. |
| The document cannot be parsed | Check its syntax with the JSON Formatter and Validator. |
The viewer requires strict JSON and rejects comments, trailing commas, and duplicate names within one object. Repeating sku in different objects, as this example does, is allowed.
For large documents, keep the viewer’s limits in mind: 1,000,000 UTF-16 code units, 200 nesting levels, and 100,000 JSON values. Parsing can also stop if it exceeds the allowed processing time or work. If that happens, try a smaller section of the document to find the field you need.
Previews show up to 120 UTF-16 code units. If text is cut off, check the original JSON for the full value.
When you need a JSONPath query
We looked up one sku in this example. To get every item’s product code at once, use a tool that runs JSONPath queries. The tree viewer doesn’t run those queries or support searching or editing the document.