fjordtools / Data / JSONPath

JSONPath Tester

Test JSONPath queries on JSON in your browser, as in RFC 9535: filters, slices and functions, with the path of each match. Nothing leaves this tab.

JSONPath
JSON
Matches as JSON

      
Paths of the matches

About JSONPath

What is JSONPath?

JSONPath is a query language for JSON, standardised as RFC 9535 in 2024. A query such as $.store.book[[email protected] < 10].title picks values out of a document the way an XPath picks nodes out of XML. This tester follows the RFC, shows every match with its normalized path, and runs in your browser, so the JSON is never uploaded.

Syntax at a glance

$ is the root. .name or ['name'] selects a member, [0] and [-1] select array elements from the start or the end, * selects every child, and [1:3] is a slice with an optional step. .. searches all descendants, so $..price finds every price at any depth. A bracket can hold several selectors: $['a','b'].

Filters and functions

[?expr] keeps the children for which the expression is true. Inside it @ is the child being tested. Compare with ==, !=, <, <=, >, >=, combine with &&, || and !, or test that something exists: [[email protected]]. The functions are length(), count(), value(), match() and search(). The last two take an I-Regexp pattern (RFC 9485), a portable subset of regular expressions without lookahead, backreferences or shorthand classes such as \d.

Example

On the sample document, $.store.book[[email protected] < 10].title returns the titles of the two books under 10. $..book[-1] returns the last book, and $..book[[email protected]] returns the books that have an ISBN.

Errors you may see

A query is checked before it runs. A leading zero ([01]), a name with a dash written with a dot ($.a-b, write $['a-b']), single or double quotes that do not match, and a function used with the wrong kind of argument all give a message and the position in the query. Results are never silently wrong: a query the standard does not allow is refused.

Differences between implementations

Before RFC 9535 every library had its own dialect, so a query that works in one may not in another. Common differences are the result for a missing path (an empty list or an error), filter syntax, and whether $.a.b on a document with duplicate keys picks the first or the last. This tool follows the RFC; with duplicate names it takes the last, like JSON.parse.

Next steps

Tidy the document first with the JSON formatter, convert it with YAML, JSON and TOML, or test a pattern for match() in the regex tester.

Privacy

The JSON is parsed and queried in your browser, in a background worker that is stopped after 1.5 seconds if a pattern or query runs away. Nothing is sent to a server, so it is safe to paste API responses and config files. Large numbers and key order are kept exactly as written.

Related tools