Skip to content

JSONPath Tester

This JSONPath tester runs your expression against your JSON as you type and shows every match with its path.

Input · JSON

2 matches

$.store.book[0].title
"Sayings of the Century"
$.store.book[2].title
"Moby Dick"
Valid JSONRuns in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

How to test a JSONPath expression

  1. Paste JSON or press Open file.
  2. Type an expression in the box above the results. Matches update as you type, and the box keeps your last query.
  3. Each match shows its normalized path, such as $.orders[2].total, and its value. The count covers every match; the first 300 are listed.

Examples

Results from this document:

{
  "orders": [
    { "id": "A-1041", "status": "shipped", "total": 42.5, "customer": { "name": "Lea", "country": "DE" }, "items": [{ "sku": "TEA-12", "qty": 2 }] },
    { "id": "A-1042", "status": "pending", "total": 18, "customer": { "name": "Omar", "country": "FR" }, "items": [{ "sku": "MUG-02", "qty": 1 }, { "sku": "TEA-19", "qty": 3 }] },
    { "id": "A-1043", "status": "shipped", "total": 7.25, "customer": { "name": "Ana", "country": "PT" }, "items": [] }
  ]
}
Expression Returns
$.orders[*].id "A-1041", "A-1042", "A-1043"
$..sku "TEA-12", "MUG-02", "TEA-19"
$.orders[?(@.status == 'shipped')].total 42.5, 7.25
$.orders[?(@.items.length > 1)].id "A-1042"
$.orders[0,2].customer.name "Lea", "Ana"
$.orders[-1:].id "A-1043"
$.orders[0].*~ "id", "status", "total", "customer", "items"

.. searches at any depth, * matches every key or item, [0,2] picks positions, and [-1:] slices from the last item. ~ returns key names, an extra that jsonpath-plus adds along with ^ for the parent of a match.

Filters

[?( )] keeps the items where the expression is true, with @ as the current item. Compare with ==, !=, < and >=, combine with &&, || and !, read .length, and call string methods such as .includes('ship'), .startsWith('A') or .match(/^O/). Quote string values: @.status == shipped fails with “shipped is not defined”.

Filters run in the safe mode of jsonpath-plus, a small interpreter that does not use eval or Function.

How this JSONPath tester differs from RFC 9535

JSONPath became a standard with RFC 9535 in February 2024. jsonpath-plus follows the older syntax:

  • Filters need parentheses. [?(@.total > 10)] works; the RFC form [?@.total > 10] returns no matches and no error.
  • [-1] returns nothing. Use [-1:] for the last item.
  • Reading a property of something missing throws an error. @.items[0].sku fails on an order with no items; guard it with @.items[0] && @.items[0].sku == 'MUG-02'.

Find a path without writing one

Click a value in the JSON viewer tree to copy its JSONPath, or put the cursor on it in the viewer’s editor and read the status bar. A syntax error in your JSON shows its line and column here, and the JSON validator explains it. For XML, use the XPath tester.

Questions

Is JSONPath the same as jq?

No. jq is a command-line tool with its own language: .orders[].id instead of $.orders[*].id. Expressions written for one do not run in the other.

Are keys case-sensitive?

Yes. $.Orders finds nothing in a document whose key is orders.

How do I use JSONPath in JavaScript?

Install jsonpath-plus, the library this page runs, and call JSONPath({ path: "$..sku", json: data }). It returns an array of the matching values.

Related tools

Esc