How to test a JSONPath expression
- Paste your JSON into the left panel, upload a
.jsonfile, or load it from a URL. Click Sample to load a small bookstore document to experiment with. - Type an expression in the JSONPath box on the output toolbar, or pick one of the suggestions that appear when you focus it. The query re-runs as you type (or press Enter), and the toast shows the match count, for example 3 matches.
- The matches appear on the right as a JSON array. Switch to Tree to expand nested results.
- Click Copy or Download .json to keep the extracted values.
If the input is not valid JSON, the error bar shows the line and column; click Fix to repair it.
Example
Input:
{
"store": {
"books": [
{ "title": "JSON at Scale", "author": "A. Rao", "price": 29.99, "inStock": true },
{ "title": "Structured Logging", "author": "B. Lee", "price": 18.5, "inStock": false },
{ "title": "APIs by Example", "author": "C. Diaz", "price": 24, "inStock": true }
],
"location": { "city": "Pune", "country": "IN" }
}
}
Expression $.store.books[?(@.price < 25)] reports 2 matches:
[
{ "title": "Structured Logging", "author": "B. Lee", "price": 18.5, "inStock": false },
{ "title": "APIs by Example", "author": "C. Diaz", "price": 24, "inStock": true }
]
JSONPath syntax in brief
$is the root. On its own it returns the whole document as a one-element array..keyselects a property:$.store.location.citygives["Pune"].[*]selects every element of an array:$.store.books[*].titlegives the three titles.[?(@.price < 25)]is a filter, where@is the element being tested.[?(@.inStock)]keeps elements whose property is truthy, so$.store.books[?(@.inStock)].authorgives["A. Rao", "C. Diaz"]...is recursive descent:$..cityfinds acitykey at any depth.[-1:]is a slice:$.store.books[-1:]gives the last book,[0:2]the first two.
Limits and notes
- Files up to 5 MB. Queries run as JavaScript in your browser; nothing is uploaded.
- The suggestions are written around the sample document.
$and$..citywork on any document, but a suggestion such as$.store.books[*].titleonly matches JSON with that shape; type your own path for your data. - The engine is jsonpath-plus. Its filters accept JavaScript-style comparisons such as
<,==and&&; other implementations (Java JsonPath, jq, Postgres) differ in details, so test expressions in your target library too. - Results are values only; matched paths are not listed. The tree view's copy-path button gives the path of any selected value.
- For the differences between the two addressing schemes, see JSONPath vs JSON Pointer. For the shell equivalent, see the jq cheat sheet, and to turn nested matches into flat columns, see flatten nested JSON.