What is JSONPath?
JSONPath is a query language for JSON, first proposed by Stefan Goessner in 2007 as a JSON equivalent of XPath (XML's query language). After 17 years of de facto standardization, JSONPath was finally formalized in RFC 9535 (February 2024). It provides a consistent way to navigate, filter, and extract data from JSON documents using path expressions like $.store.books[0].title.
Why JSONPath matters
Modern systems pass JSON everywhere. JSONPath gives you a single query language for all of them — log search (Elasticsearch, Datadog), API testing (Postman), configuration (Kubernetes kubectl jsonpath), ETL pipelines (Airflow, Dagster), AWS Step Functions ($.input.field), GitHub Actions context expressions. Learning JSONPath once pays dividends everywhere.
How JSONPath compares
- JSONPath — read-only query, simple syntax, RFC 9535 standard
- JMESPath — alternative spec used by AWS CLI, more functional features (sort, map, filter)
- JQ — full programming language for JSON, command-line tool
- JSON Pointer (RFC 6901) — minimal path syntax, no wildcards, used in JSON Patch
How to Use This Tool
- Paste your JSON into the input textarea.
- Click Parse JSON (or press
Ctrl+Enter) to build the tree view. - Click any node in the tree — its full JSONPath expression and value appear in the right panel.
- Use Copy Path to copy the JSONPath (
$.users[0].name) or Copy Value to copy just the value at that path. - Click Sample to load an example JSON tree to explore the tool quickly.
Privacy: All parsing and tree-building happens in your browser. JSON contents stay local.
JSONPath Syntax (RFC 9535)
Core operators
$ root object / array
@ current element (in filters)
.field child by name (dot notation)
['field'] child by name (bracket notation, allows special chars)
..field recursive descent — find anywhere in tree
[n] array index (0-based)
[start:end] array slice (Python-style)
[*] all elements (wildcard)
[?(expr)] filter expression
Filter operators (in expressions)
== equal != not equal
< less than <= less or equal
> greater than >= greater or equal
&& logical AND || logical OR
! negation =~ regex match (RFC 9535)
Functions (RFC 9535)
length(@) length of string/array/object
count(...) count matched nodes
match(@.field, /re/) regex match
search(@.field, /re/) regex search
Path comparison
JSON Pointer (RFC 6901) is similar but simpler — no wildcards or filters, just slashes: /store/book/0/title. JSONPath is more expressive; JSON Pointer is more constrained but unambiguous.
Practical Examples
Sample JSON for the examples below:
{
"store": {
"books": [
{ "title": "Sapiens", "price": 18.99, "author": "Harari" },
{ "title": "Dune", "price": 12.99, "author": "Herbert" },
{ "title": "Stoner", "price": 14.99, "author": "Williams" }
],
"bicycle": { "color": "red", "price": 199 }
}
}Basic queries
$.store.books[0].title → "Sapiens"
$.store.books[*].author → ["Harari", "Herbert", "Williams"]
$..price → [18.99, 12.99, 14.99, 199]
$.store.books.length → 3 (with length() function)
Filters
# Books cheaper than $15
$.store.books[?(@.price < 15)]
→ [Dune, Stoner objects]
# Book titles by Harari
$.store.books[?(@.author == "Harari")].title
→ ["Sapiens"]
# Items priced between 100-300
$..[?(@.price >= 100 && @.price <= 300)]
→ [bicycle object]
Slicing
$.store.books[0:2] → first 2 books
$.store.books[-1:] → last book
$.store.books[::2] → every other book (0, 2)
$.store.books[1:] → all except first
Real-world patterns
# Kubernetes — get pod IPs
kubectl get pods -o jsonpath='{.items[*].status.podIP}'
# AWS Step Functions — extract input field
{ "ResultSelector": "$.statusCode" }
# Postman test — assert API response
pm.expect(responseJson).to.have.jsonPath('data.user.id');
# jq equivalent (similar but different syntax)
.store.books | map(select(.price < 15))FAQ
What libraries use JSONPath?
Python: jsonpath-ng, jsonpath-rw. JavaScript: jsonpath-plus, @jsonpath-tools/jsonpath (RFC 9535 compliant). Java: Jayway JsonPath. Go: spyzhov/ajson. Plus tools — Postman, kubectl jsonpath=, AWS Step Functions, GitHub Actions, Elasticsearch.
Is there a size limit?
Browser memory dependent. JSON files up to several MB work smoothly. Very deeply nested (100+ levels) or huge arrays (100k+ items) may affect tree rendering performance — but parsing still works.
What's the difference between JSONPath and JMESPath?
Both query JSON. JSONPath (RFC 9535) is more concise for simple queries — closer to XPath. JMESPath (used by AWS CLI) has stronger functional features (sort, map, projection) and stricter typing. For ad-hoc API testing, JSONPath is more common; for cloud automation, JMESPath dominates.
How does JSONPath compare to jq?
jq is a full programming language for JSON — much more powerful (transformations, computations, scripting). JSONPath is a read-only query language — simpler, portable across many tools. Use JSONPath for path queries, jq for transformations.
Why does .. (recursive descent) seem slow?
$..field visits every node in the tree to find matches anywhere. On large JSON, this is O(N). Prefer specific paths ($.users[*].name) when you know the structure — they're O(1) per match.
Can JSONPath modify data?
Standard JSONPath is read-only — selects and returns. For modifications, use JSON Patch (RFC 6902, separate operations like add/remove/replace using JSON Pointers) or jq's transformation features.
Why did JSONPath need an RFC after twenty years?
Because every implementation had drifted. The 2007 original was a blog post with a reference implementation, not a specification, so libraries in different languages disagreed on filters, on how to handle missing keys, and on whether results kept document order. RFC 9535, published in 2024, finally pins the behaviour down — but older libraries still ship the pre-RFC semantics, which is why the same expression can return different results in Python and JavaScript.
What is the difference between $.. and $.*?
A single asterisk matches direct children only, while the double dot is a recursive descent that searches every level below the current node. $.store.* returns what is directly inside store; $..price finds every price anywhere in the document, however deeply nested. The recursive form is enormously useful and enormously easy to make accidentally expensive on large documents.
Is JSONPath the same as JMESPath or jq?
No, and mixing their syntax is a common source of confusion. JSONPath is a query language for selecting nodes. JMESPath, used heavily by the AWS CLI, can also reshape output into new structures. jq is a full stream-processing language with its own filters, variables, and control flow. If a filter you copied from a blog post does not work, check which of the three it was written for.
Why does my filter expression return nothing?
Usually a type mismatch. JSON distinguishes the number 5 from the string “5”, so a filter comparing against a number will not match a value stored as text. The second common cause is comparing against a key that does not exist on every element — behaviour there differs between implementations, with some skipping the element and others raising an error.
Can JSONPath modify a document?
The specification covers selection only. Some libraries add extension methods for setting or deleting matched values, but that behaviour is not standardised, so code relying on it is tied to one library. For transformation rather than selection, jq or a purpose-written function is the better tool.
Is my JSON sent anywhere when I test an expression?
No. Evaluation runs entirely in your browser, which matters because the documents people paste into a path tester are very often real API responses containing customer data.