JSON Path
Query a document with JSONPath expressions
JSONPath is to JSON what XPath is to XML: a compact expression language for addressing parts of a document. A path begins at the root with $, walks into properties with dots or brackets, indexes arrays, and can descend recursively with two dots to find a key at any depth without knowing the structure above it.
It earns its place when you are extracting a handful of values from a large or unpredictable response — pulling every id out of a nested result set, or filtering objects by a property. Long treated as a de facto convention with implementation-specific quirks, it was finally standardised as RFC 9535 in 2024, which is slowly reducing the differences between libraries.
How to use it
- Paste the JSON documentThe response or file you want to query. It is parsed in this tab, so nothing is sent anywhere.
- Write a pathStart with $ and build up. $.items[0].name addresses one value; $..name finds every name at any depth.
- Refine with filtersA filter expression such as $.items[?(@.price > 10)] selects by condition, where @ refers to the element currently being tested.
Frequently asked questions
What do $ and @ mean?
$ is the root of the document and every path starts there. @ is the current node inside a filter expression, so $.books[?(@.price < 10)] reads as "from the books array, take each element where that element’s price is under ten".
What is the difference between one dot and two?
A single dot moves one level: $.store.book selects the book property of store. Two dots descend recursively: $..book finds every book property anywhere in the document, at any depth. The recursive form is powerful and expensive, since it walks the whole structure.
How do I select a range of array items?
With slice syntax borrowed from Python: [0:3] takes the first three, [-2:] the last two, and [::2] every second element. Slices are one of the areas where older implementations diverged most, so behaviour at the edges is worth testing rather than assuming.
How is JSONPath different from JMESPath or jq?
JSONPath selects existing nodes and returns them. JMESPath and jq can also reshape the result — building new objects, mapping and reducing — which makes them more powerful and more complex. If you only need to pull values out, JSONPath is the smaller idea; if you need to transform, jq is the better tool.
What happens if a path matches nothing?
You get an empty result rather than an error, because a path is a query and matching nothing is a legitimate answer. That is convenient and it hides typos: a misspelled property name returns exactly the same empty result as a genuinely absent one.