JSONPath Tester
Test JSONPath expressions against JSON data in real time. View matched results with syntax highlighting. Supports filters, wildcards, and recursive descent. Free, browser-based.
- Runs in your browser
- Tool input is not uploaded to ZeroTool servers
- Free · No Sign-Up
Scan with WeChat to share this tool
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.
JSONPath Syntax Reference (RFC 9535)
$— root of the document.key,['key'],["key"]— member of an object[n],[-1]— array element; negative indexes count from the end[start:end:step]— slice, for example[0:2],[1:],[::-1][0,2],['title','price']— several selectors in one bracket; results follow the order of the selectors[*],.*— all array elements or object member values..key,..[0],..*— descendants at any depth[?@.price < 10]— filter; also written[?(@.price < 10)][?@.isbn],[?!@.isbn]— members that exist / do not exist[?@.a.b == 'x' && @.c > $.min]— nested paths,&&||!, and absolute $ paths inside a filterlength(),count(),match(),search(),value()— the five functions defined by RFC 9535
Limitations
- Syntax errors and syntax outside RFC 9535 are rejected with "Invalid or unsupported syntax" and the character position. Syntax outside RFC 9535 includes script expressions
[(...)],=~,in/nin, and extensions such as~for member names from other libraries. $.store.book.lengthselects a member namedlength, which arrays do not have, so the result is empty. Uselength()inside a filter, for example$[?length(@.book) > 3].- Results list the matched values. Normalized paths (such as
$['store']['book'][0]) are not shown. - Object members come back in the order JavaScript keeps them: names that are array indexes, such as
"2"or"10", first and in ascending order, then the other names in the order of your JSON (ECMA-262 OrdinaryOwnPropertyKeys). The pretty-printed Results use the same order. RFC 9535 §2.3.2.2 leaves the order open, so other implementations can differ. - If an object has the same name twice,
JSON.parsekeeps the last value and the query never sees the first one. - Member names are compared code point by code point, with no Unicode normalization (RFC 9535 §2.3.1.2 for name selectors; the tool compares strings in filters the same way):
étyped as one character does not select a name stored aseplus a combining accent. match()andsearch()run the pattern as a JavaScript regular expression with theuflag after changing.to[^\n\r](RFC 9485 §5.3). Patterns that JavaScript rejects give false; JavaScript-only syntax such as\dor lookahead is accepted.- Numbers are JavaScript numbers after
JSON.parse. Integers above 253, very long decimals,-0and numbers too large for a double change before they are compared and shown; the status line lists them (see the example below). - The invalid-JSON message is the browser's own JavaScript parser message, so its wording depends on the browser.
Examples on the Sample Data
The page opens with a small bookstore document: four books and a bicycle. These are the tool's results for it:
| Expression | Result |
|---|---|
$.store.book[?@.price < 10].title | ["Sayings of the Century","Moby Dick"] (2 matches) |
$.store.book[-1].author | "J. R. R. Tolkien" (1 match, shown as the value itself) |
$..price | [8.95,12.99,8.99,22.99,19.95]: the four book prices, then the bicycle |
$.store.book[?@.isbn].title | No matches found: no book in the sample has an isbn member |
$.store.book[(@.length-1)] | Invalid or unsupported syntax: script expressions such as [(@.length-1)] are not part of RFC 9535; use a negative index such as [-1] (at character 14) |
Example: an ID Larger Than 253
An order export that stores 64-bit IDs as JSON numbers looks fine in the input box, but a filter for one ID can match two orders:
{"orders": [
{"id": 9007199254740993, "total": 25.0},
{"id": 9007199254740992, "total": 10}
]}
$.orders[?@.id == 9007199254740993].total returns [25,10], and the status line reads
2 matches · Numbers that JavaScript cannot hold exactly (1): 9007199254740993 → 9007199254740992. Filters and Results use the JavaScript value.
Both IDs become the same double, so the comparison cannot tell them apart; 25.0 is also shown as 25, which is the same value and is not listed.
RFC 8259 §6 says only integers in the range −(253)+1 to 253−1 are interoperable. Send such IDs as strings and compare them as strings: [?@.id == '9007199254740993'].
When exactly one value matches, the Results panel shows that value on its own; with two or more, it shows a JSON array. Copy takes the panel as shown, so a single string is copied with its quotes. Results are pretty-printed with two-space indentation.
Other JSONPath Dialects
Many tools say “JSONPath” but implement a different language. An expression that works here may need changes elsewhere, and the reverse:
- kubectl uses JSONPath templates: the expression goes inside braces, the leading
$is optional, and there are extra keywords such asrangeandend, as inkubectl get pods -o jsonpath='{.items[*].metadata.name}'. Paste only the part inside the braces here, with$added in front. - Jayway JsonPath (Java) and libraries based on Stefan Goessner's 2007 article accept script expressions, the
=~regex operator and functions such as.length()at the end of a path. This tool follows RFC 9535 and rejects them with the position of the problem. - AWS Step Functions accepts JsonPath in fields such as
InputPath, but a reference path such asResultPathmust point to a single node and cannot use filters, wildcards or slices, which this tool accepts.
To reshape JSON rather than only select from it, use the jq Playground; to check the document first, use the JSON Formatter.
FAQ
What is JSONPath?
JSONPath is a query language for JSON, analogous to XPath for XML. It uses a path expression to select nodes from a JSON document. RFC 9535 (2024) standardizes it. Variants of it appear in kubectl output templates, AWS Step Functions and many API testing tools.
What does $ mean in a JSONPath expression?
$ refers to the root element of the JSON document. Every valid JSONPath expression must start with $. On its own, $ selects the entire document. You chain selectors after it, such as $.store.book[0].title; [*] selects every element of an array, so $.store.book[*].author returns every author.
How do filter expressions work?
A filter is written [?expression], and @ is the element being tested. Under RFC 9535 the parentheses are optional, so $.store.book[?@.price < 10] and $.store.book[?(@.price < 10)] are the same. You can use ==, !=, <, <=, >, >=, combine conditions with &&, || and !, test nested paths such as @.author.name, compare with other parts of the document through $, and call length(), count(), match(), search() and value(). A string never equals a number: a price stored as "9.99" is not less than 10.
What is recursive descent (..) ?
The .. operator recursively searches all descendants of the current node. For example, $..author finds every author field anywhere in the JSON tree, regardless of nesting depth.
Why do I see "Invalid or unsupported syntax"?
The expression has a syntax error, such as an unclosed string or bracket, or uses syntax that RFC 9535 does not define. The tool stops and shows the reason and the character position instead of returning an empty result. Common cases of syntax outside RFC 9535 are script expressions such as [(@.length-1)] (use [-1]), the =~ operator (use match() or search()), and in / nin. "No matches found" means the expression is valid but nothing in the JSON matches it; if the expression has full-width characters such as . or [, the status line says so, because JSONPath reads them as part of a name.
Is my JSON sent anywhere or saved?
No. The query runs in the page script on this page; the JSON and the expression are not sent to a server and are not written to browser storage. Analytics records only the tool name and an action: a committed query that finds matches, an example click or a copy. It does not record the JSON or the expression.