Free tool
JSONPath tester
Type a JSONPath expression and see every match, with its path, as you type. Switch to the document view to see matches highlighted in your JSON, and click any key or item to get its path.
Free · no sign-up · runs in your browser, nothing is uploaded
Loading JSONPath…
JSONPath cheat sheet
Results are for the sample bookstore document in the tester (load it with [sample]).
| Expression | Means | Result on the sample |
|---|---|---|
| $ | The root of the document | the whole document |
| $.store.bicycle.color | Child by name (dot notation) | ["red"] |
| $['store']['bicycle']['color'] | Child by name (bracket notation, for keys with spaces or dashes) | ["red"] |
| $.store.book[0].title | Array item by index, from 0 | ["Sayings of the Century"] |
| $.store.book[-1].title | Index from the end (RFC 9535) | ["The Lord of the Rings"] |
| $.store.book[*].author | Wildcard: every item or property | 4 authors |
| $..author | Recursive descent: at any depth | 4 authors |
| $.store.* | Every child of store | the book array and the bicycle |
| $..book[0,1].title | Union of indexes | first two titles |
| $..book[1:3].title | Slice [start:end], end excluded | ["Sword of Honour", "Moby Dick"] |
| $..book[::2].title | Slice with a step | items 0 and 2 |
| $..book[?(@.isbn)].title | Filter: key exists | ["Moby Dick", "The Lord of the Rings"] |
| $..book[?(@.price < 10)].title | Filter: comparison | ["Sayings of the Century", "Moby Dick"] |
| $..book[?(@.category == "fiction" && @.price > 10)] | Filter: && and || | 2 books |
| $..book[?(@.author.match(/tolkien/i))] | Filter: regex (jsonpath-plus) | 1 book |
| $.store.*~ | Property names (jsonpath-plus) | ["book", "bicycle"] |
| $..* | Every value in the document | 27 values |
Filters, and how implementations differ
JSONPath existed for 17 years as a 2007 blog post before RFC 9535 standardised it, so libraries disagree on the details. This tester runs jsonpath-plus, which follows Goessner's original syntax with extras, and rewrites two common RFC forms so they work too: filters without parentheses ([?@.price < 10]) and negative indexes ([-1]).
| Feature | Goessner / jsonpath-plus | RFC 9535 |
|---|---|---|
| Filter | [?(@.price < 10)] | [?@.price < 10] |
| Last item | [-1:] (a slice) | [-1] |
| Regex | @.title.match(/x/i) | match(@.title, 'x') or search() |
| Array length | @.length (JavaScript) | length(@) |
| Strings | single or double quotes | single or double quotes |
RFC 9535 function extensions such as length(), count(), match(), search() and value() are not available here. Filters run in jsonpath-plus's safe evaluator, which supports comparisons, &&, ||, ! and property access, without running arbitrary JavaScript.
JSONPath in code and on the command line
JavaScript with jsonpath-plus:
import { JSONPath } from 'jsonpath-plus';
const titles = JSONPath({ path: '$..book[?(@.price < 10)].title', json: data });
// ['Sayings of the Century', 'Moby Dick']Python with jsonpath-ng (filters need the ext parser):
from jsonpath_ng.ext import parse
titles = [m.value for m in parse('$..book[?(@.price < 10)].title').find(data)]kubectl uses JSONPath templates in curly braces, and the leading $ is optional:
kubectl get pods -o jsonpath='{.items[*].metadata.name}'
kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.phase}{"\n"}{end}'JSONPath vs jq vs JMESPath
Three query languages for JSON with different syntax. The same query, titles of books under 10, in each:
| Language | Query | Where you meet it |
|---|---|---|
| JSONPath | $..book[?(@.price < 10)].title | Kubernetes, API testing tools, many libraries |
| jq | .store.book[] | select(.price < 10) | .title | Command line, shell scripts |
| JMESPath | store.book[?price < `10`].title | AWS CLI --query, Azure CLI, Ansible |
| PostgreSQL | $.store.book[*] ? (@.price < 10).title | jsonb_path_query() in SQL |
PostgreSQL's SQL/JSON path looks like JSONPath but puts filters after the step (? (@.price < 10)), so expressions do not copy across unchanged.
Gotchas
- Keys are case-sensitive.
$.Storefinds nothing in a document withstore. - Quote keys with spaces, dashes or dots.
$.first-namedoes not work; write$['first-name']. - No match is not an error. A wrong path returns an empty list. Check each step from the left, or click the key in the document view to get the exact path.
- .. can be slow and broad.
$..idalso matches ids inside nested objects you did not mean. Use the full path when you know it.
Format or repair the JSON first with the JSON formatter, describe its shape with the JSON Schema generator or JSON to TypeScript, and find more API tools in API tools on DevHunt.
More free developer tools
FAQ
What is JSONPath?+
JSONPath is a query language for JSON, in the spirit of XPath for XML. $ is the document root, .name or ['name'] picks a property, [0] an array item, * every child, .. searches at any depth, and [?( )] filters by a condition. Stefan Goessner described it in 2007, and RFC 9535 standardised it in February 2024.
How do I filter an array by a value in JSONPath?+
Use a filter: $.store.book[?(@.price < 10)] returns the books with a price under 10. @ is the item being tested. Combine conditions with && and ||, test that a key exists with [?(@.isbn)], and compare strings with == "fiction". RFC 9535 writes the same filter without parentheses, [?@.price < 10]; this tester accepts both.
Why is the JSONPath result always an array?+
A JSONPath can match any number of nodes: none, one or many, so evaluators return a list. Even $.store.bicycle.color returns ["red"]. In code, take the first item when you expect a single value, and handle the empty list when the path does not exist.
What is the difference between JSONPath and JSON Pointer?+
JSON Pointer (RFC 6901) addresses exactly one value with a plain path like /store/book/0/title, and has no wildcards or filters. JSON Patch and JSON Schema errors use it. JSONPath is a query that can match many values. The tester shows each match in both forms.
How do I get the last item of an array?+
In RFC 9535, $.store.book[-1]. Older implementations such as jsonpath-plus need a slice, $.store.book[-1:], which returns a one-item list. This tester rewrites [-1] to the slice for you, so both work.
How do I get the keys of an object with JSONPath?+
Standard JSONPath returns values, not names. jsonpath-plus adds ~ for property names: $.store.*~ returns ["book", "bicycle"]. In plain JavaScript, Object.keys(obj) is simpler.
Is my JSON uploaded?+
No. The expression runs in your browser with the open source jsonpath-plus library, using its safe evaluator for filters. Nothing is sent to a server. Short inputs are kept in the page URL so you can share a result.
Sources: RFC 9535: JSONPath · RFC 6901: JSON Pointer · Stefan Goessner: JSONPath (2007) · jsonpath-plus · jsonpath-ng · kubectl JSONPath support · jq manual · JMESPath · PostgreSQL SQL/JSON path. Checked 2026-10-29.