📄 JSON document
Paste any JSON document. The page ships with the classic Goessner bookstore as a starting point.
🔍 JSONPath expression
🧪 Try a classic example
📊 Summary
📋 Matches
ℹ️ About JSON Path Evaluator
What JSONPath does
JSONPath is a query language for JSON documents — the analogue of XPath for XML. Stefan Goessner's
original 2007 paper proposed the dollar-rooted dotted/bracket syntax ($.store.book[*].author)
and the IETF formalised the language as RFC 9535 in 2024. This page implements the
classic Goessner surface plus the RFC 9535 features that matter in practice: recursive descent
(..), wildcards (*), array slices ([0:5:2]), filter
expressions ([?(@.price < 10)]), and the length() function.
The evaluator runs entirely in your browser via a hand-rolled parser — there is no
eval(), no external library, and no document is sent off-machine when you use the UI.
The same TypeScript logic module powers the API endpoint below, so the browser and the server
agree byte-for-byte on which paths match a given query.
Classic JSONPath examples (Goessner 2007)
All examples below operate on the canonical bookstore document Goessner used in his paper:
| JSONPath | Result |
|---|---|
$.store.book[*].author | The authors of all books in the store |
$..author | All authors anywhere in the document (recursive descent) |
$.store.* | All things in the store — books and bicycle |
$..price | The price of everything in the store |
$..book[2] | The third book |
$..book[-1] | The last book in order (negative index) |
$..book[0:2] | The first two books (slice) |
$..book[?(@.isbn)] | All books with an ISBN number (existence filter) |
$..book[?(@.price < 10)] | All books cheaper than 10 |
$..* | All members of the JSON document |
Supported syntax
- Root —
$matches the document itself. - Child segments —
.foo,['foo'],["foo"]. Bracket form is required for property names that aren't valid identifiers. - Wildcard —
*or[*]matches every member of an object or every element of an array. - Recursive descent —
..collects every descendant before applying the next segment. Useful for "find any property called X" queries. - Array indexing —
[0],[3],[-1](last),[-2](second-to-last). Out-of-bounds indices simply produce no match. - Array slice —
[start:end]or[start:end:step]using the same semantics as Python slicing. - Multi-key union —
['title','price']selects multiple sibling keys in a single step. - Filter expressions —
[?(@.price < 10)],[?(@.isbn)],[?(@.author == 'J. R. R. Tolkien')]. Supported operators:==,!=,<,<=,>,>=,&&,||. - length() function —
length(@.tags)returns the size of a string, array, or object, suitable for comparison inside a filter ([?(length(@.tags) > 0)]).
Use cases
- API testing — extract the response field you actually care about from a verbose JSON payload during smoke tests, regression diffs, or curl/jq exploration.
- Schema exploration — locate every property of a given name across a deeply nested
document with
$..fieldName. - Filtering large arrays — find records that match a predicate
(
[?(@.status == 'failed' && @.attempts > 3)]) without writing throwaway JavaScript. - Pipeline scripting — generate a list of normalised paths to feed into another tool
(each match carries both the dotted
$.store.book[0].titleform and the canonical bracket form$['store']['book'][0]['title']). - Documentation — illustrate a JSON schema by showing example JSONPath queries and the matches they return, alongside the document itself.
Path notation in the results
Every match carries two path strings:
- Dotted form —
$.store.book[0].title. Human-friendly, mirrors the query language. Useful for talking to teammates. - Normalised bracket form —
$['store']['book'][0]['title']. The RFC 9535 "normalised path" — unambiguous, machine-parseable, safe for keys that contain dots or other punctuation.
Error reporting
- Invalid JSON input surfaces as
Invalid JSON: <parser message>. - Syntax errors in the expression include a position offset
(
Unexpected token "@" at position 3). - Out-of-range array indices and missing object properties simply produce no match — they aren't treated as errors, matching the Goessner / RFC 9535 behaviour.
References
- Stefan Goessner — "JSONPath: XPath for JSON" (2007). The original syntax, including the canonical bookstore example used as the page's default document.
- RFC 9535 — JSONPath: Query Expressions for JSON (IETF, 2024). The current standard, formalising filter expressions, slices, recursive descent, and the normalised path form.
- RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format. The substrate JSONPath operates on.
API Usage Example:
POST /api/tools/data/json-path-evaluator
Content-Type: application/json
{
"document": {
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
},
"expression": "$..author"
}