Query and extract data from JSON using JSONPath expressions. Paste your JSON, write a path expression, and see matching results instantly. Free, no signup required.
JSONPath is a query language for JSON documents, analogous to how XPath is used to query XML. It provides a concise expression syntax for navigating the structure of a JSON document and extracting specific values, arrays, or sub-objects. JSONPath was originally proposed by Stefan Goessner in 2007 and has since become one of the most widely used tools in the JSON ecosystem.
A formal standard for JSONPath has now been published as RFC 9535 (2024), replacing the informally-specified original version with a rigorous definition. Most libraries implement a superset of the original Goessner spec.
JSONPath is embedded in many popular tools and specifications:
kubectl output formattingThe following table covers the core JSONPath operators and what each one does:
| Operator | Description | Example |
|---|---|---|
$ | Root element. Every path starts here. | $ |
. | Child operator. Access a named property. | $.user.name |
.. | Recursive descent. Find key at any depth. | $..name |
[n] | Array index (zero-based). | $.items[0] |
[start:end] | Array slice (like Python). | $.items[0:3] |
* | Wildcard. Matches all children. | $.users[*].email |
[?(expr)] | Filter expression. Select by condition. | $.items[?(@.price < 50)] |
@ | Current node (used inside filters). | @.active == true |
[a,b,c] | Union. Select multiple indices or keys. | $.items[0,2,4] |
Given this sample JSON document representing a bookstore:
{
"store": {
"book": [
{ "category": "fiction", "title": "Dune", "author": "Frank Herbert", "price": 8.99 },
{ "category": "fiction", "title": "Neuromancer", "author": "William Gibson", "price": 11.99 },
{ "category": "reference", "title": "Pro Git", "author": "Scott Chacon", "price": 0 }
],
"location": "New York"
}
}
| JSONPath Expression | Result |
|---|---|
$.store.book[0].title | "Dune" |
$.store.book[*].author | ["Frank Herbert", "William Gibson", "Scott Chacon"] |
$..price | [8.99, 11.99, 0] |
$.store.book[?(@.price > 9)] | [ Neuromancer object ] |
$.store.book[?(@.category == "reference")] | [ Pro Git object ] |
$.store.book[-1:] | [ Pro Git object ] (last element) |
JSONPath was explicitly modeled on XPath, so the two share many conceptual similarities. However, there are important differences that reflect the structural differences between JSON and XML:
/ for the root; JSONPath uses $./ (e.g., /store/book); JSONPath uses . (e.g., $.store.book).//; JSONPath uses ...@attr in XPath); JSON has no attribute concept, so @ in JSONPath refers to the current node in a filter.For most practical use cases involving JSON APIs and data processing, JSONPath's simpler model is more than sufficient and is easier to learn than the full XPath specification.
JSONPath is a query language for JSON, similar to how XPath works for XML. It lets you navigate and extract specific values from a JSON document using a path expression syntax. JSONPath was originally proposed by Stefan Goessner in 2007. A standardized version is now defined in RFC 9535 (2024). It is widely supported in libraries for Java, Python, JavaScript, Go, and many other languages.
The $ symbol represents the root of the JSON document. Every valid JSONPath expression must start with $ to indicate you are querying from the top level of the document. For example, $.store.book[0].title retrieves the title of the first book in the store object starting from the document root.
A single dot (.) is the child operator and accesses an immediate child property. For example, $.user.name accesses the name property directly inside user. Two dots (..) are the recursive descent operator and search for a key at any depth in the document. For example, $..name finds every name field no matter how deeply nested it appears in the structure.
Use the filter expression syntax with [?()]. The @ symbol refers to the current element being evaluated. For example, $.store.book[?(@.price < 10)] returns all book objects where the price property is less than 10. You can use comparison operators (==, !=, <, >, <=, >=) and string comparisons in filter expressions.
Free, instant, 100% private. No account needed.
JSONPath (RFC 9535) is a query language for JSON data that lets you extract specific values from nested structures using path expressions. Think of it as XPath but for JSON.
// Sample JSON
{"store":{"books":[{"title":"A","price":9},{"title":"B","price":15}],"owner":"Alice"}}
// Expressions and results
$ → entire document
$.store.owner → "Alice"
$.store.books[0].title → "A"
$.store.books[*].price → [9, 15]
$..title → ["A", "B"] (recursive)
$.store.books[?(@.price > 10)].title → ["B"]
| Operator | Description |
|---|---|
| $ | Root element — start all expressions here |
| . | Child element: $.name |
| .. | Recursive descent — searches all depths |
| [n] | Array element at index n (0-based) |
| [*] | All array elements |
| [n:m] | Array slice from index n to m |
| [?(@.key)] | Filter — elements where key exists |
| [?(@.key == val)] | Filter — elements where key equals value |
// Extract all emails from a user list
$.users[*].email
// Find orders over $100
$.orders[?(@.total > 100)]
// Get the last item in an array
$.items[-1]
// Get all values of a specific key at any depth
$..id
// Count items (wrap in array)
$.items.length
This comprehensive table covers every major JSONPath operator and its behavior.
| Expression | Description | Example |
|---|---|---|
$ | Root element | $ → entire document |
.key | Child property | $.name → value of name |
..key | Recursive descent | $..id → all id values at any depth |
[n] | Array index (0-based) | $.items[0] → first item |
[-1] | Last array element | $.items[-1] → last item |
[*] | All array elements | $.items[*] → all items |
[n:m] | Array slice | $.items[0:3] → first 3 |
[?(@.x)] | Filter: key exists | Elements where x exists |
[?(@.x == v)] | Filter: equals | Elements where x equals v |
[?(@.x > v)] | Filter: greater than | Elements where x > v |
{
"store": {
"books": [
{"title": "Clean Code", "price": 29, "inStock": true},
{"title": "Refactoring", "price": 35, "inStock": false},
{"title": "The Pragmatic Programmer", "price": 32, "inStock": true}
],
"owner": "Alice"
}
}
$.store.owner → "Alice"
$.store.books[0].title → "Clean Code"
$.store.books[*].title → ["Clean Code","Refactoring","The Pragmatic Programmer"]
$.store.books[-1].price → 32
$..price → [29, 35, 32]
$.store.books[?(@.inStock)].title → ["Clean Code","The Pragmatic Programmer"]
$.store.books[?(@.price < 33)].title → ["Clean Code","The Pragmatic Programmer"]
$.store.books[0:2].title → ["Clean Code","Refactoring"]
Also useful: JWT Decoder | JSON Validator | JSON Formatter | JSON Diff | JSON Schema Validator | JSON to TypeScript