Somewhere inside a JSON document is the one value you actually need: the title of the first book, every price anywhere in the file. The document might be an API response thousands of lines long, and the manual method is scrolling and hoping your eyes catch the right key. It is slow, and on a bad day it is wrong, because two keys with the same name in different places look identical.
JSONPath exists to make that lookup exact. It is a small query language for JSON: you write a path that describes where the value lives, and the engine returns every match, each with its full concrete path attached. The JSON Path Tester on Ovatly runs a documented subset of the language against a document you paste, entirely in your browser.
Contents
- Quick answer
- Building a path piece by piece
- Wildcards: every item at once
- Bracket keys for awkward names
- Recursive descent: find a key anywhere
- How to query JSON, step by step
- Worked example: every book title in the store
- When the tester says no
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Paste your JSON into the JSON Path Tester, type a path starting with $, such as $.store.book[0].title, and press Run path. The tool lists every matched value with its concrete path, or shows a plain-language error if the syntax is unsupported. One honest warning: this tester runs a documented subset of JSONPath. Filters, slices, scripts and unions are not supported and produce an explicit error, and a result of 0 matches is a valid answer, not a failure.
Building a path piece by piece
A JSONPath expression is read left to right, one step at a time, starting from the root, written $. Each step narrows the selection:
.keysteps into the value of that key in an object, so$.storeselects whatever sits under the store key.[index]picks one item out of an array by position, counting from zero, so$.store.book[0]is the first book.- Steps chain:
$.store.book[0].titlewalks from the root into the store, takes the first book, and selects its title.
Build the path incrementally and run it as you go. Start with $.store, confirm you are standing in the right object, then add the next step. A path built in stages fails at the step that is wrong, which makes it obvious whether the problem is a misspelled key, an array where you expected an object, or a forgotten level of nesting.
Wildcards: every item at once
An index picks one item; the wildcard [*] picks all of them. Placed where an index would go, it continues the path into every element of the array, so $.store.book[*].title collects the title of every book. The wildcard also works over objects, applying the rest of the path to every value it holds.
Wildcards turn JSONPath from a lookup into an extraction: instead of repeating a query once per array position, one expression gathers the whole column of values, each listed with its own concrete path so you can see which item it came from.
Bracket keys for awkward names
Dot notation assumes keys are tidy identifiers. Real documents contain keys with dots, spaces and other punctuation, and for those there is bracket notation: $['my.key'] treats the quoted text as a single key. Without the brackets, $.my.key would be read as two steps, into my and then into key, and would find nothing or the wrong thing. Single or double quotes both work. When a dot path returns nothing and the key contains punctuation, bracket notation is the first fix.
Recursive descent: find a key anywhere
Sometimes you do not know where a key lives: prices might sit at the top level of one record and three levels down in another. Recursive descent, written ..key, searches at any depth and returns every occurrence. The path $..price finds every price key in the file, each listed with its full concrete path, so the result doubles as a map of where that data hides. It is also the fastest way to explore an unfamiliar document, since the returned paths reveal its real structure.
How to query JSON, step by step
- Open the JSON Path Tester and paste your JSON document into the input box.
- Type a path starting with
$, building it in stages if you are unsure of the structure. - Press Run path.
- Read the matches, each listed with its concrete path, or read the error and adjust the expression.
- Refine: add an index to narrow to one item, a wildcard to gather all of them, or
..keyto search at any depth.
Worked example: every book title in the store
Take a small store document with two books:
{"store":{"book":[{"title":"Dune"},{"title":"Emma"}]}}
The precise path to the first title is $.store.book[0].title. Swap the index for a wildcard and the query becomes a collection:
$.store.book[*].title
Running it returns both titles, each labelled with the concrete path it came from:
$.store.book[0].title = "Dune"
$.store.book[1].title = "Emma"
Those concrete paths are the point: they prove the values came from the places you intended, and if the document later changes shape, comparing returned paths against what you expected is how you notice.
When the tester says no
Two kinds of "no" come back from the tester, and they mean different things. The first is 0 matches: the path is valid, the document simply contains nothing at that address. That is a real answer about your data, not an error.
The second is an unsupported-syntax error. This tester implements a documented subset of JSONPath: the root, dot keys, indexes, wildcards, bracket keys and recursive descent. Filters such as [?(...)], slices such as [0:2], scripts and unions are outside it. Use one and you get a clear error naming the unsupported part, never a silent empty result that you might mistake for "no matches". The fix is to rewrite the query in the supported pieces, gathering with a wildcard and filtering yourself, or to take it to a full JSONPath library.
Limitations and honest tradeoffs
The subset is the limitation: if your question is inherently conditional, such as "every book cheaper than 10", this tester cannot ask it, because that needs a filter. What it can do is gather every price with $..price, or every title with a wildcard, and leave the comparison to you or to code.
The tester also answers questions about the document you pasted, exactly as pasted. It does not fetch data from a URL, and a path that works on a sample may return 0 matches on a differently shaped real document. Treat it as a precise instrument for exploration and verification.
Common mistakes
- Writing a filter and expecting results. Filters are outside the subset and return an explicit error; rewrite with keys, indexes and wildcards, or use a full library.
- Forgetting the
$. Every path starts at the root symbol; without it, the expression has no anchor. - Using dot notation for a key that contains a dot.
$.my.keyis two steps. A key with punctuation in it needs bracket notation:$['my.key']. - Treating 0 matches as a crash. It is the correct answer for a valid path that matches nothing. Check the path against the document's structure before blaming the tool.
- Merging the two kinds of "no". The tester never answers unsupported syntax with an empty list. An error message and 0 matches are different outcomes.
FAQs
Is this the full JSONPath language? No. The tester runs a small, documented subset: the root $, dot keys, indexes, wildcards, bracket keys and recursive descent. Filters, slices, scripts and unions are not supported, and using one produces a clear error naming the unsupported part rather than a silent empty result.
Why did my filter expression fail?
Filters such as [?(...)] are outside the supported subset. Rewrite the query with keys, indexes and wildcards, or take the filter to a full JSONPath library in your own code.
What does 0 matches mean? It means the path is valid but nothing in the document matches it. That is a real answer, not a failure: the tool reports 0 matches instead of guessing at what you might have meant.
How do I get every value with a given key, wherever it appears?
Use recursive descent. The path $..price finds every price key at any depth in the document and lists each match with its full concrete path.
Can I query a key that contains a dot or a space?
Yes, with bracket notation. Writing $['my.key'] treats the whole quoted text as one key, where $.my.key would be read as two separate steps.
Conclusion
A JSONPath query is just an address, built one step at a time: root, key, index, wildcard, and recursive descent when depth is unknown. The JSON Path Tester answers with matches and their concrete paths, and it is honest about its edges: a documented subset, explicit errors, and 0 matches treated as a real answer. When the data you are exploring starts life in a spreadsheet instead, our guide to turning a CSV file into an HTML table covers that conversion. For more guides in this series, see our Data and JSON Tools guides.
References
- RFC 9535, the JSONPath standard: https://www.rfc-editor.org/rfc/rfc9535
- MDN Web Docs, on JSON and working with JSON data: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON