Skip to main content
ponderloop

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

Starts with $. Results update as you type; nothing is uploaded.

Example expressions (click one to run it on the sample)

2 matches

2 nodes selected.

Matches
2
Segments
4
Can match at most one node
No

The working

  1. Start at the root node $, the whole document (1 node).
  2. .store: 1 node left.
  3. .book: 1 node left.
  4. [?@.price < 10]: 2 nodes left.
  5. .title: 2 nodes left.

Supported syntax

Every row is run by this tool on the sample document; the last column is the number of matches it returns.
SyntaxMeaningExampleMatches in sample
$The root: the whole document$1
.name or ['name']A member of an object$.store.name1
[n]An array element; a negative n counts from the end$.store.book[-1].title1
*Every member or element$.store.book[*].title4
..Descendant segment: the node and everything below it$..price5
[start:end:step]A slice of an array; end is excluded; step may be negative$.store.book[1:3].title2
[a, b]A union: several selectors in one bracket, results kept in order$.store.book[0,2].title2
[?expr]A filter: keep the children for which expr is true$.store.book[?@.price < 10].title2
@.xAn existence test: true when the query finds at least one node$..book[?@.isbn].title2
== != < <= > >=Comparisons of numbers, strings, booleans, null, arrays and objects$..book[?@.category == 'fiction'].title2
&& || !AND, OR and NOT, with ( ) for grouping$..book[?@.category == 'fiction' && !@.isbn].title1

Standard functions

RFC 9535 section 2.4. Arguments are type-checked before the query runs, so a mistake is reported with its position.
FunctionWhat it doesReturnsExampleMatches in sample
length(v)Characters of a string (Unicode code points), elements of an array, members of an objectA number, or nothing for other types$..book[?length(@.tags) > 1].title2
count(nodes)Number of nodes a query findsA number$..book[?count(@.tags[?@ == 'classic']) == 1].title1
match(s, regex)Whether the whole string matches the regular expressiontrue or false$..book[?match(@.category, 'fiction|history')].title3
search(s, regex)Whether any part of the string matches the regular expressiontrue or false$..book[?search(@.title, '^The ')].title2
value(nodes)The single value a query finds, or nothing when it finds none or severalA value$..book[?value(@.tags[0]) == 'nature'].title1

Not supported, or different from the RFC

FeatureStatus
Script expressions such as [(@.length-1)]Not in RFC 9535. Use a negative index: [-1].
Regex comparison @.title =~ /x/iNot in RFC 9535. Use match() or search().
Parent ^, property-name ~ and other Goessner or library extrasNot in RFC 9535, so not supported.
Custom function extensionsOnly the five standard functions exist. Calling any other name is an error.
Strict I-Regexp (RFC 9485) validationPatterns 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 queryThe RFC rejects it; this tool ignores it so pasted queries work.
Numbers beyond double precision in comparisonsCompared as 64-bit floats. In results, numbers are printed exactly as written.
Duplicate keys in the JSONThe last value wins, as in JSON.parse; the key keeps its first position.
More than one million visited nodesStopped with an error so the page does not freeze.

How to test a JSONPath expression

  1. 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.
  2. Type an expression. Start with $ and add segments, for example $.store.book[?@.price < 10].title. Or click one of the example expressions.
  3. 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.
  4. 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: Formatters and data convertersAll developer toolsAll toolsHome & DIY calculators