How to use the JSONPath tester
- Paste your document into JSON. The sample is the classic bookstore example.
- Type an expression in JSONPath expression. It must start with
$. - Read the count under Result, then the Matched values as a JSON array.
- Use the Matches with paths table to see exactly where each value lives.
What it does and when to use it
JSONPath picks values out of a JSON document, the way XPath does for XML. It is used in API test tools, Kubernetes kubectl -o jsonpath, AWS Step Functions, log processors and many SDKs. Getting an expression right inside those tools is slow, because you often only see the final result. Here you see every match and its path as you type, so you can check a filter against real data before pasting it into a test or config.
If you only need to filter an array by field conditions, without JSONPath syntax, try JSON query. To list every path in a document so you know what to select, use the JSON key extractor. For a quick structural view first, the JSON formatter helps.
Syntax reference
| Expression | Selects |
|---|---|
$.a.b or $['a']['b'] |
a child by name |
$.list[0], $.list[-1] |
an item by index, negative from the end |
$.list[0,2] |
several indexes (a union) |
$.list[1:3], $.list[::-1] |
a slice, start to end (end excluded), optional step |
$.a.*, $.list[*] |
every child |
$..price |
price at any depth |
[?(@.x > 5)], [?@.x] |
items passing a filter, or items that have x |
[?(@.name =~ /^a/i)] |
regex match (tool extension) |
[?(@.tags.length > 2)] |
length of an array, string or object (tool extension) |
How it works
The selectors follow RFC 9535, minus its function extensions. The expression is compiled into a list of steps, and each step is applied to the current set of matches, starting from the root. A .. step visits every level below. Filters run once per array item or object member, with @ set to that item; $ inside a filter refers to the whole document. Matches keep document order. Everything runs in your browser.
Worked examples
With this data:
{"orders":[{"id":1,"total":25,"status":"paid"},
{"id":2,"total":140,"status":"paid","coupon":"VIP"},
{"id":3,"total":60,"status":"refunded"}]}
$.orders[?(@.status == 'paid' && @.total > 50)].id → $.orders[1].id | 2
$.orders[?@.coupon].id → $.orders[1].id | 2
$.orders[-1:].status → $.orders[2].status | "refunded"
$.orders[*].total → 3 matches: 25, 140, 60
An expression without the leading $, such as orders, returns A JSONPath starts with $ (at character 1).
Limits and tips
- When a filter compares missing fields, two missing sides are equal, as RFC 9535 says, so
@.x == @.ymatches items that have neither; a missing field never equals a real value. - Very large documents with
..on many levels can take a moment, since every node is visited.
Frequently asked questions
Does this follow RFC 9535?
Why do I get no matches?
Can I do arithmetic in a filter?
Which regular expression syntax does =~ use?
In what form are the result paths shown?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.