Guide
What Is JSONPath? A Practical Introduction with Examples
JSONPath is a query language for picking values out of JSON, much like XPath for XML. It was standardised as RFC 9535 in 2024 and is used in API testing tools, Kubernetes, AWS Step Functions and many databases.
We’ll use this document for all the examples:
{
"store": {
"name": "Corner Books",
"books": [
{ "title": "Dune", "price": 9.99, "tags": ["sci-fi"] },
{ "title": "Emma", "price": 6.5, "tags": ["classic", "romance"] }
]
}
}
The basics
| Expression | Result |
|---|---|
$ |
The whole document (the root) |
$.store.name |
"Corner Books" |
$.store.books[0].title |
"Dune" |
$.store.books[-1].title |
"Emma" (last item) |
$['store']['name'] |
"Corner Books" (bracket notation) |
Use dot notation for simple keys. Use bracket notation for keys that contain spaces, dashes or dots, for example $['content-type'].
Wildcards and recursion
| Expression | Result |
|---|---|
$.store.books[*].title |
["Dune", "Emma"] |
$..price |
Every price anywhere: [9.99, 6.5] |
$.store.books[0:1] |
A slice containing the first book |
Filters
Filters select array items that match a condition. @ refers to the current item.
$.store.books[?@.price < 8].title → ["Emma"]
$.store.books[?@.tags[0] == 'sci-fi'] → the Dune object
Getting the path to any value
Writing a long path by hand is easy to get wrong. In the JSON tree viewer, click any node and choose Copy path. You get its exact JSONPath, such as $.store.books[1].tags[0], ready to paste into your code or tests.