Evaluate a JSONPath expression and see every match with the path that produced it
Enter JSON and an expression to see the matches here.
JSONPath is an expression syntax for pulling values out of a JSON document. It is XPath's idea applied to JSON; the notation proposed by Stefan Goessner in 2007 became the de facto common form. $ is the whole document (the root), and you walk down from there with . and [].
For example $.store.book[0].title means "the title of element 0 of the book array inside store". Array indexes start at 0. Counting from 1 is the most common first mistake.
| Syntax | Meaning |
|---|---|
$ | Root. Every expression starts here |
.name / ['name'] | Step into a key. Use ['...'] for keys with symbols or spaces |
[0] / [-1] | Array index. Negative counts from the end |
[1:3] | Array slice. From 1 up to but not including 3 |
[*] / .* | Every element at that level |
..name | Recursive descent. Collects name at any depth |
[?(@.k > 10)] | Filter. @ is the current element. == != < <= > >= are available |
[?(@.k)] | Only elements that have key k (existence test) |
[0,2] / ['a','b'] | Union of several selections |
These three do not work here and produce an explicit error rather than an empty result, because a stated reason is easier to act on than silence.
[0:10:2])[(@.length-1)], because arbitrary JavaScript is never evaluated&&, ||) inside a filter. One comparison per filter.. walks the document depth-first from the top. With the sample above, $..price returns 8.95, 12.99, 8.99, 22.99, 19.95. The bicycle price comes last because the book array is written first. Document order is result order.
Everything is evaluated in your browser with JavaScript. Nothing you paste is sent to a server. The syntax follows Stefan Goessner's JSONPath (https://goessner.net/articles/JsonPath/ ).
JSON Pointer (RFC 6901) addresses exactly one value, written as /store/book/0/title, with no wildcards or filters. JSONPath is built to pull out many values at once, so $..price means "every price, at any depth". Use Pointer to name one place, JSONPath to select by condition.
It is recursive descent: it visits every level below that point and collects each element that has the key. Use it when the depth is unknown or the same key appears at several levels. If the count is higher than you expected, check the path column to see what it also picked up.
Wrap it in single or double quotes, as in $.store.book[?(@.category == 'fiction')]. Without quotes the value is read as a number or a keyword and the expression fails.
No. Parsing and evaluation both happen in your browser with JavaScript, so production data you paste never leaves the page.