Enter a JSONPath expression to query
Enter a JSONPath expression to query
Paste JSON on the left, type a JSONPath expression like $.store.book[*].title, and the matches appear as a JSON array with a match count. It supports $, dot and bracket keys, [*], indexes including negative ones, slices with any step, unions like [0,2], .. recursive descent and filters like [?(@.price < 10 && @.isbn)]. Results follow RFC 9535, in document order, and it runs in your browser.
By Ankit Aglawe · Updated · Runs entirely in your browser
The filter keeps array elements where the condition holds, then .title picks one field from each. <, >, <= and >= only compare numbers, so Neuromancer, whose price is the string "12.00", never matches a numeric comparison.
Query: $.store.book[?(@.price < 10)].title
{
"store": {
"name": "Corner Books",
"book": [
{ "title": "Dune", "author": "Frank Herbert", "price": 9.99, "isbn": "978-0441013593" },
{ "title": "Emma", "author": "Jane Austen", "price": 4.5 },
{ "title": "Neuromancer", "author": "William Gibson", "price": "12.00", "isbn": null },
{ "title": "Ulysses", "author": "James Joyce", "price": 15 }
],
"bicycle": { "color": "red", "price": 120 }
}
}[
"Dune",
"Emma"
]Filters can reach into nested fields with dots (@.status.restarts). This is the same shape kubectl get pods -o json returns, so the query is a quick way to test before using it in a script.
Query: $.items[?(@.status.restarts > 1)].metadata.name
{
"kind": "PodList",
"items": [
{ "metadata": { "name": "api-7d9f", "labels": { "app": "api" } }, "status": { "phase": "Running", "restarts": 0 } },
{ "metadata": { "name": "api-2k1x", "labels": { "app": "api" } }, "status": { "phase": "CrashLoopBackOff", "restarts": 14 } },
{ "metadata": { "name": "worker-5c8n", "labels": { "app": "worker" } }, "status": { "phase": "Running", "restarts": 2 } }
]
}[
"api-2k1x",
"worker-5c8n"
]$..price finds every price at any depth, in document order: on the bookstore example it returns [9.99, 4.5, "12.00", 15, 120], the books first and the bicycle last. $..* and $..[0] work too.
Filters take comparisons (==, !=, <, >, <=, >=), existence checks like @.isbn, and combine them with &&, ||, ! and parentheses: [?(@.price > 5 && @.price < 10)]. Paths inside a filter can index arrays (@.tags[0]) and can start from the root (@.price < $.limit). Both [?(...)] and the RFC form [?...] are accepted. Regex =~ and functions such as length() are not supported and show an error instead of an empty result.
== compares type and value, as RFC 9535 says, so [?(@.price == "15")] does not match the number 15. < and friends compare numbers with numbers and strings with strings; mixed types never match. An existence check counts a key set to null as present: [?(@.isbn)] matches both Dune and Neuromancer above.
A filter runs over the elements of an array or the member values of an object. $.store[?(@.color == "red")] tests book and bicycle and returns the bicycle.
[0:2] takes the first two elements, [-1] and [-1:] the last, and [::-1] the whole array reversed. [0,2], [-1,0] and ['title','price'] are unions: each selector runs in turn and the results are joined in that order.
$.store.book.length returns [4], because arrays have a length property. Some JSONPath engines return nothing for this, others need .length(). Do not rely on it being portable.
store.name fails with "JSONPath must start with $". Keys with spaces or dots need bracket notation, like $['store']['name']. A path that matches nothing returns [], not an error.
| Expression | Meaning | Example |
|---|---|---|
$ | The root | $ |
.key / ['key'] | Child by name | $.store.name |
..key | Every key at any depth | $..author |
* / [*] | All children of an object or array | $.store.* |
[n] | Index, negative counts from the end | $.store.book[-1] |
[start:end:step] | Slice, end exclusive | $.store.book[::-1] |
[a,b] | Union of indexes, names or slices | $.store.book[0,-1] |
[?(@.field op value)] | Filter array elements | $..book[?(@.price > 10)] |
[?(a && b || !c)] | Combine conditions | $..book[?(@.isbn && @.price < 10)] |
[?(@.field)] | Elements that have the key | $..book[?(@.isbn)] |
Enter the JSON data you want to query in the main editor. Any valid JSON object or array is accepted.
Type a JSONPath query like $.store.book[*].title or $..price in the expression field. Results update in real time as you type.
The output pane shows all values matching your JSONPath expression, formatted as a JSON array. Copy the results or refine your query.
Paste your JSON on the left and type the expression into the query box on the right. The matching values update on every keystroke, with a count of matches.
It is recursive descent: $..name finds every name key anywhere in the document, at any depth. Matches come back in document order.
Use [?(@.field == "value")] on the array, for example $.users[?(@.role == "admin")].email. Quote strings; numbers and true, false, null go bare.
Yes. Use && and || with parentheses and ! for negation, for example $.store.book[?(@.price > 5 && @.price < 10)].
Nothing matched. Unsupported syntax such as regex or functions shows an error instead. A common cause is == with the wrong type: "15" does not equal 15. Check the path one step at a time from $.
No. JSONPath only selects values; jq can also transform them. JSONPath is the syntax behind kubectl -o jsonpath and AWS Step Functions paths.
Need several formats at once? Convert All shows every output from one paste. Or browse all JSON converters.