JSONPath Tester lets you try a JSONPath query against your own JSON and see exactly what it matches. Every result is shown with the path it came from, so you can tell which item in an array a value belongs to. It runs in your browser, so you can paste a real API response.
How to test a JSONPath query
- Paste your JSON, or click Example for a sample document.
- Type a query, or pick one from Examples you can click.
- Matches appear as you type, each with its full path.
The syntax, briefly
| Write this | To get |
|---|---|
$ | The whole document |
$.store.name | One property, step by step |
$.book[0] | The first item; arrays start at 0 |
$.book[-1:] | The last item |
$.book[0:2] | A slice: the first two |
$.book[*].title | One field from every item |
$..price | Every price at any depth |
$.book[?(@.price < 10)] | Only the cheap ones; @ is the item being tested |
$..book[?(@.isbn)] | Items that have a field at all |
When a query returns nothing
Usually the path does not match the shape of the data. Build it up one step at a time: start with$, confirm it matches the whole document, then add $.store, then$.store.book, and so on. The step where the matches disappear is the step that is wrong. A common trip-up is expecting an object where the data actually has an array.
Filters
A filter like [?(@.price < 10)] keeps only the items where the test passes. Comparisons (<, >, ===) and existence checks (@.isbn) both work. Arbitrary JavaScript inside a filter does not, because this page does not allow code to be built and run at runtime, which is also what keeps a pasted document safe.
Related tools
To make a response readable first, use the JSON Formatter. To check a document against a set of rules rather than pull values out of it, use theJSON Schema Validator, and to generate types from an example, useJSON to TypeScript.
Frequently asked questions
What is JSONPath?
A small query language for JSON, in the spirit of CSS selectors for HTML. A path like $.store.book[0].title picks out one value, and $..price finds every price at any depth.
What do $, .. and * mean?
$ is the whole document, a dot steps into a property, .. searches at any depth below, and * matches every child. So $..book[*].title is every book title anywhere in the document.
Can I filter on a value?
Yes. $.store.book[?(@.price < 10)] returns the books under 10, where @ means "the item being tested". Comparisons and existence checks work; running arbitrary JavaScript does not, because this page forbids it.
Why does my query return nothing?
Usually the path does not match the shape of the data. Start from $ and add one step at a time, checking the matches as you go. Remember arrays are numbered from 0.
Is my JSON uploaded?
No. The query runs in your browser, so you can safely paste a real API response.
Last updated