JSONPath Tester
JSONPath selects values from a JSON document with a path expression. On the sample bookshop below, $.store.book[?@.price < 10].title gives 2 matches: “The Salt Road” and “Letters from the Ice”. Paste your own JSON, type an expression following RFC 9535, and the matched values, their normalized paths and any error with its position appear as you type.
Updated By ponderloop editorial · How we checkRuns in your browser: nothing you enter is uploadedHow this tool works
2 matches
2 nodes selected.
- Matches
- 2
- Segments
- 4
- Can match at most one node
- No
The working
- Start at the root node $, the whole document (1 node).
- .store: 1 node left.
- .book: 1 node left.
- [?@.price < 10]: 2 nodes left.
- .title: 2 nodes left.
Supported syntax
| Syntax | Meaning | Example | Matches in sample |
|---|---|---|---|
| $ | The root: the whole document | $ | 1 |
| .name or ['name'] | A member of an object | $.store.name | 1 |
| [n] | An array element; a negative n counts from the end | $.store.book[-1].title | 1 |
| * | Every member or element | $.store.book[*].title | 4 |
| .. | Descendant segment: the node and everything below it | $..price | 5 |
| [start:end:step] | A slice of an array; end is excluded; step may be negative | $.store.book[1:3].title | 2 |
| [a, b] | A union: several selectors in one bracket, results kept in order | $.store.book[0,2].title | 2 |
| [?expr] | A filter: keep the children for which expr is true | $.store.book[?@.price < 10].title | 2 |
| @.x | An existence test: true when the query finds at least one node | $..book[?@.isbn].title | 2 |
| == != < <= > >= | Comparisons of numbers, strings, booleans, null, arrays and objects | $..book[?@.category == 'fiction'].title | 2 |
| && || ! | AND, OR and NOT, with ( ) for grouping | $..book[?@.category == 'fiction' && !@.isbn].title | 1 |
Standard functions
| Function | What it does | Returns | Example | Matches in sample |
|---|---|---|---|---|
| length(v) | Characters of a string (Unicode code points), elements of an array, members of an object | A number, or nothing for other types | $..book[?length(@.tags) > 1].title | 2 |
| count(nodes) | Number of nodes a query finds | A number | $..book[?count(@.tags[?@ == 'classic']) == 1].title | 1 |
| match(s, regex) | Whether the whole string matches the regular expression | true or false | $..book[?match(@.category, 'fiction|history')].title | 3 |
| search(s, regex) | Whether any part of the string matches the regular expression | true or false | $..book[?search(@.title, '^The ')].title | 2 |
| value(nodes) | The single value a query finds, or nothing when it finds none or several | A value | $..book[?value(@.tags[0]) == 'nature'].title | 1 |
Not supported, or different from the RFC
| Feature | Status |
|---|---|
| Script expressions such as [(@.length-1)] | Not in RFC 9535. Use a negative index: [-1]. |
| Regex comparison @.title =~ /x/i | Not in RFC 9535. Use match() or search(). |
| Parent ^, property-name ~ and other Goessner or library extras | Not in RFC 9535, so not supported. |
| Custom function extensions | Only the five standard functions exist. Calling any other name is an error. |
| Strict I-Regexp (RFC 9485) validation | Patterns are translated to JavaScript regular expressions: . excludes only line breaks, match() anchors the whole string. A pattern JavaScript rejects counts as no match; a pattern valid in JavaScript but outside I-Regexp (a lookahead, a backreference) is accepted here. |
| Leading or trailing white space around the query | The RFC rejects it; this tool ignores it so pasted queries work. |
| Numbers beyond double precision in comparisons | Compared as 64-bit floats. In results, numbers are printed exactly as written. |
| Duplicate keys in the JSON | The last value wins, as in JSON.parse; the key keeps its first position. |
| More than one million visited nodes | Stopped with an error so the page does not freeze. |
How to test a JSONPath expression
- Paste your JSON. Put the document in the JSON box, or keep the sample bookshop. A JSON error is shown with its line and column.
- Type an expression. Start with $ and add segments, for example $.store.book[?@.price < 10].title. Or click one of the example expressions.
- Read the matches. The tool lists the matched values as JSON and the normalized path of each one. For the example that is 2 matches.
- Follow the working. The working shows how many nodes are left after every segment, which tells you where an expression stops matching.
Frequently asked questions
- What is JSONPath, and what is RFC 9535?
- JSONPath is a query language for picking values out of JSON, like XPath for XML. Stefan Goessner described it in 2007 and many libraries copied it with small differences. RFC 9535, published in February 2024, is the IETF standard that fixes one grammar and one set of rules. This tool follows the RFC. On the sample document, $..price finds 5 prices at any depth and $.store.book[*].title finds 4 titles.
- How is JSONPath different from jq?
- JSONPath only selects: its result is always a list of nodes that already exist in the document. jq is a full language that can also build new objects, do arithmetic, group, sort and reshape. Use JSONPath when you need to point at values (in a config, an API test or a log filter) and jq when you need to transform them. JSONPath is a standard with many implementations; jq is one program with its own syntax.
- How does RFC 9535 differ from the original Goessner JSONPath?
- The RFC fixes what the 2007 article left open. Filters are written [?@.price < 10] and parentheses are optional, so [?(@.price < 10)] still works (both give 2 here). Script expressions like [(@.length-1)] are gone, so use [-1]. Regex comparison with =~ is replaced by the match() and search() functions. A comparison with a missing member is defined: nothing equals only nothing. Strings can use single or double quotes with fixed escapes. Result order, duplicates and the type of every function argument are specified. Older libraries may still return different results for edge cases.
- What is the difference between $..title and $.store.book[*].title?
- The first walks every level below the root and picks every member named title, so it also finds the magazine title: 5 matches. The second names the path exactly and finds only the 4 book titles. Descendant search is convenient but can match more than you expect.
- Why does @.isbn == null not find books without an isbn?
- A missing member is not the same as null. The expression $..book[?@.isbn == null] matches 0 books, because the comparison is between nothing and null, and that is false. To find books with no isbn, negate an existence test: $..book[?!@.isbn] matches 2. To find books where isbn is present, use $..book[?@.isbn] (2 matches).
- What is the difference between match() and search()?
- match() is true only when the whole string fits the pattern; search() is true when any part does. With the pattern 'The' on the sample titles, match(@.title, 'The') finds 0 books and search(@.title, 'The') finds 2. Both return false for values that are not strings. Patterns use the I-Regexp dialect of RFC 9485, a small, portable subset of regular expressions.
- What are normalized paths?
- A normalized path is the one canonical way to write the location of a node, with every name in single quotes and every index as a number, for example $['store']['book'][0]['title']. It tells you exactly where each match came from, even when the expression used .., * or a filter. RFC 9535 defines the format in section 2.7.
- How do negative indexes and slices work?
- A negative index counts from the end: $.store.book[-1] is the last book and [-2] the one before it. A slice [start:end:step] takes the elements from start up to, but not including, end. Leave a part out for its default, and use a negative step to go backwards: $.store.book[::-1].title lists 4 titles in reverse order. An index or slice that falls outside the array does not raise an error; it selects fewer nodes or none.
- Is my JSON uploaded anywhere?
- No. The expression is parsed and evaluated in your browser, nothing you paste is sent to a server or stored, and the analytics event for this tool never includes the JSON or the expression.
- Which parts of RFC 9535 are not supported?
- Everything in the grammar is implemented: all five selectors, both segment types, filters with all operators, and the five standard functions. The differences are small and listed in the table above: regular expressions are JavaScript ones that follow the I-Regexp conventions rather than a strict I-Regexp checker, white space around the whole query is ignored, and a query that visits more than a million nodes is stopped.
How it works
The query is parsed with a recursive-descent parser written from the ABNF grammar in RFC 9535 section 2, including its rules for singular queries and function argument types. It is then evaluated against the parsed JSON as a list of nodes, one segment at a time: each selector turns every node of the previous step into zero or more nodes, and a descendant segment first expands every node into itself and all of its descendants. Slices use the normalization and bounds formulas of section 2.3.4.2. Comparisons treat a missing value as nothing, as section 2.3.5.2 requires. For $.store.book[?@.price < 10].title the result is 2 matches. Results are not de-duplicated, so a union such as [0,0] returns the same node twice, as the RFC specifies.
Sources
More free tools
- JSON to CSV ConverterConvert JSON, an object of arrays or JSON Lines to CSV or TSV in your browser. Flattens nested keys to address.city, quotes per RFC 4180, guards formulas.
- JSON to TypeScript Interface GeneratorPaste JSON and get TypeScript interfaces or types: named nested interfaces, ? on optional keys, unions for mixed arrays. Runs in your browser.
- YAML Formatter & ValidatorValidate YAML with the line and column of any error, re-indent with 2 or 4 spaces, sort keys or convert to JSON. Keeps most comments. Runs in your browser.
- JSON Schema ValidatorValidate JSON against a JSON Schema (draft 2020-12 and 07 subset): every error with its path and rule, exact decimals, optional format checks.
- Online Markdown Editor With Live PreviewWrite Markdown with a live, safe preview. Toolbar, shortcuts, word count, copy HTML, download .md and an autosaved draft. Runs in your browser.
- JSON Formatter & ValidatorValidate JSON with the exact line and column of any error, then pretty-print, minify or sort keys. Big numbers keep every digit. Runs in your browser.
More: Formatters and data convertersAll developer toolsAll toolsHome & DIY calculators