JSONPath: Locate Values in Nested JSON
Read root, property, and array-index paths, including keys with punctuation, and understand the viewer’s copy-path feature.
JSONPath expressions select values inside JSON. $ represents the root. Named children and array indexes let you follow a particular branch. The standard is RFC 9535.
{
"team": [
{ "name": "Alex", "active": true },
{ "name": "Sam", "active": false }
],
"build.version": "1.2"
}
$["team"][0]["name"] selects "Alex". Indexes start at zero. $["build.version"] selects the property literally named build.version; the dot is part of that name.
A location versus a query
A path to one node is useful for describing where an error or value lives. Broader queries can select multiple nodes: $["team"][*]["name"] selects both names. Check the JSONPath implementation you use, especially for expressions beyond simple child and index selection.
Copy a path from the viewer
Open the sample in the JSON viewer, expand a branch, and choose path beside a node. The viewer produces bracket notation and escapes quotes or backslashes in property names. Choose value to copy that node’s original JSON text instead.
Copying a path does not execute a JSONPath query. Paste it into the JSONPath query tester to run it against a document. The viewer’s search only filters keys and value excerpts in its bounded tree preview. If a document contains duplicate property names, a copied path cannot distinguish those occurrences reliably. The query tester rejects duplicate names; copy value in the viewer still uses the selected occurrence’s source range.
The tester supports root, child names, array indexes, wildcards, and recursive names. It does not support filters, slices, or unions. For instance, $.team[*].name selects both names in the example above, but a filter such as $.team[?@.active] is outside this tool’s supported subset.
Paths are not JavaScript to execute
Treat a copied path as data. Do not feed it into eval() or interpolate it into application code. A proper query library should parse expressions and document its supported syntax. Likewise, never assume an object key is a safe identifier: spaces, punctuation, quotes, and empty names are valid JSON property names.
For the underlying structures, see arrays and objects. The viewer’s full-document download remains available even when its tree preview is truncated.