JSONPath Tester

Paste JSON, type a path such as $.store.book[?(@.price < 10)].title and see each match with its path. Names, indexes, slices, wildcards, descendants and filters are supported.

Syntax follows the standard: $ is the root, .name or ['name'] picks a key, [0] and [-1] pick items, [1:3] slices, * matches everything, .. searches all levels, and [?(@.x > 1)] filters. Filters can use && || ! and the functions length, count, match, search and value.

Worked examples

A filter

$.book[?(@.price < 10)].title on {"book": [{"title": "A", "price": 8.95}, {"title": "B", "price": 12.99}]}

["A"]

Only the first book costs less than 10.

A slice from the end

$[-2:] on [10, 20, 30, 40]

[30,40]

The last two items.

About JSONPath Tester

JSONPath lets you pick values out of a JSON document with a short expression, the way a file path picks a file. It is used in API testing tools, automation platforms, log pipelines and many libraries, and the syntax has enough corners, such as filters, slices and the double dot, that it is worth testing a path before you rely on it.

Paste your JSON, type a path and the matches appear straight away. Each match is listed with its normalised path, so you can see exactly which node was reached, and the matched values are also gathered into a JSON list you can copy. The syntax follows the published standard: root $, dot and bracket names, positions including negative ones, slices with a step, wildcards, recursive descent and filters with comparisons, && and ||, and the functions length, count, match, search and value.

How to use JSONPath Tester

  1. Paste the JSON into the first box. A mistake is reported with a line and column.
  2. Type a JSONPath starting with $, for example $.store.book[*].title.
  3. Read the matches and their paths below. Change the path until it finds what you want.
  4. Copy the matched values as a JSON list.

Common uses

  • Writing the path for an API test assertion
  • Checking a filter before using it in an automation
  • Exploring an unfamiliar JSON response
  • Finding where in a big document a value lives

Frequently asked questions

What does $..price mean?

Two dots search every level below the starting point, so $..price finds every key called price anywhere in the document.

How do filters work?

A filter in square brackets keeps the children for which the condition is true. In $.book[?(@.price < 10)] the @ stands for each child in turn. You can combine tests with && and || and negate with !.

How do I pick the last item of a list?

Use a negative position. [-1] is the last item, [-2] the one before it, and [-3:] is the last three.

Why does a valid path return nothing?

A path that does not match anything gives an empty result, not an error. Check the spelling of keys, which are case sensitive, and whether the value sits inside a list that needs [*].

Do different tools give the same results?

JSONPath had no standard for many years and tools differ in the corners. This tester follows the published standard, so results can differ from older libraries for unusual expressions.