JSONPath is to JSON what XPath is to XML — a small expression language for selecting nodes from a structured document without writing code to walk it. It’s the right tool when you’re prototyping a webhook handler, exploring an unfamiliar API response, or extracting a few fields from a config file for a one-off script.
How it works
A JSONPath expression is a series of steps that filter a tree of values:
$— the root of the document.fooor['foo']— child by name[0]— child by index[*]— all children at this level..— recursive descent (every descendant)[?(...)]— predicate filter[start:end]— slice (with negative indices and step support)
The tester evaluates expressions with jsonpath-plus, which implements the most-widely-deployed JSONPath dialect. Each match comes back with its canonical bracket-notation path so you can copy paths verbatim into other tools.
Example: extracting all author names from a bookstore
JSON:
{
"store": {
"book": [
{ "author": "Nigel Rees", "title": "Sayings of the Century" },
{ "author": "Evelyn Waugh", "title": "Sword of Honour" }
]
}
}
Path: $..author (recursive descent finds every key named author).
Result: "Nigel Rees", "Evelyn Waugh" — each with its path: $['store']['book'][0]['author'], $['store']['book'][1]['author'].
Example: filtering by price
Path: $.store.book[?(@.price < 10)] — books cheaper than $10. Only the matching book objects are returned (full objects, not just one field).
Combine with field access: $.store.book[?(@.price < 10)].title — just the titles of cheap books.
Example: getting the last item of an array
Path: $.store.book[-1:] — slice from the second-to-last position. Returns the last book. Equivalent: $.store.book[(@.length-1)].
When JSONPath is the right tool
- Quick API exploration — paste a response, find the field you need without writing parser code.
- Webhook payload extraction — many automation platforms (Zapier, n8n, Make, Pipedream) use JSONPath as the field-picker syntax.
- Config inspection — pull values from Kubernetes manifests, Terraform plans, package.json files.
- Test fixture queries — assert on specific paths in API integration tests.
When to use something else
- Schema validation — JSONPath only finds nodes; it doesn’t validate types or required fields. Use JSON Schema for that.
- Mutation — JSONPath is read-only. To modify JSON in-place, use
jsonpath-plus’s callback API (programmatically, not in this tester) or a library like jsonpatch. - Heavy transformations — chain JSONPath outputs into a real script. JSONPath is for selection, not transformation.
Common gotchas
Quotes. Use single quotes inside filter expressions for string literals: ?(@.category === 'fiction'). Double quotes inside a JSONPath expression that’s already enclosed in double quotes (in source code) require escaping — single quotes sidestep the issue.
.. performance. Recursive descent visits every node in the tree. For huge documents (10k+ nodes) it can be slow. Anchor your path to a known prefix ($.store..price instead of $..price) when you can.
@ only works inside filters. @ refers to the current node during predicate evaluation. It’s an error outside ?(...).
Index-based vs slice notation. $.book[0] returns one item; $.book[0:1] returns a one-element array containing that item. Slices always return arrays; single indices return single values.
If the JSON you’re testing against is unformatted, the JSON formatter & validator will pretty-print it first; for pattern-based search inside JSON string values, the regex tester is the complementary tool.