How to test a JSONPath expression
- Paste JSON or press Open file.
- Type an expression in the box above the results. Matches update as you type, and the box keeps your last query.
- 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].skufails 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.