JSONPath syntax
$is the root;.nameor['name']selects a member, and[0]an array element ([-1]counts from the end).*selects all members or elements;..searches at every depth, so$..pricefinds every price.[1:3]is a slice (elements 1 and 2);[::2]takes every second element.[?@.price < 10]filters:@is the current item, with==,!=,<,<=,>,>=,&&,||and!.[?@.isbn]keeps items that have anisbn.[0,2]or['a','b']selects several at once.
How to use the JSONPath Tester
- Paste JSON, or choose an example query, which loads sample data.
- Type a JSONPath query. Matches update as you type.
- Select Show to jump to a match in the JSON.
- Copy the matched values as a JSON array, or their paths.
Examples
Filter by a value
query: $.books[?@.price < 10].title
data: {"books":[{"title":"Sayings","price":8.95},{"title":"Moby Dick","price":8.99},{"title":"The Lord of the Rings","price":22.99}]}[
"Sayings",
"Moby Dick"
]Every price, at any depth
query: $..price
data: {"books":[{"price":8.95},{"price":22.99}],"bicycle":{"price":399}}[
8.95,
22.99,
399
]Items with a property, and the last item
query: $.books[?@.isbn].title
data: {"books":[{"title":"A"},{"title":"B","isbn":"0-553-21311-3"},{"title":"C","isbn":"0-395-19395-8"}]}[
"B",
"C"
]$.books[-1].title would select only "C", the last book's title.
Functions
length(@.title): the length of a string, array or object.count(@.tags[*]): the number of nodes a query selects.match(@.email, '.*@example\.com'): the whole string matches a regular expression;search(@.name, 'Ada')finds it anywhere.value(@..price): the value of a query that selects one node.
Why the standard matters
Before RFC 9535, every JSONPath library had its own dialect: filter syntax (?(@.price < 10) or ?@.price < 10), what .. returns, and whether scripts were allowed all varied. Many online testers still use one of those dialects. This tester follows the standard, which newer libraries (and databases adopting SQL/JSON-style paths) implement. Older forms such as ?(…) with parentheses are still accepted, because the parentheses are valid grouping.
Limitations
- Function extensions beyond the five in RFC 9535 aren't available.
- Very large documents with
..queries can take a moment.
Frequently asked questions
Is my JSON uploaded?
No. Queries run in your browser; nothing you paste is sent anywhere.
Why doesn't my query from another tool work?
It may use a pre-standard dialect: script expressions such as $.books[(@.length-1)] and some functions aren't part of RFC 9535. Use [-1] for the last element and the standard functions instead.
What is a normalized path?
A canonical way of writing the location of one value, defined by RFC 9535, such as $['books'][0]['title']. It always uses bracket notation, so it's unambiguous even for keys with spaces or dots.
How do I find the path to a value?
Open the JSON in the JSON Viewer and select the value: its path is shown and can be copied.