How to Test JSONPath Expressions Online Against Real Data
Need to test JSONPath expressions online? Learn filter syntax, recursive descent, and array slicing with API examples. Try the free JSONPath tester now.
How to Test JSONPath Expressions Online Against Real Data
If you want to test JSONPath expressions online, you are usually holding an API response and a query that returns the wrong thing. Maybe an empty array where you expected three objects. Maybe every node in the document when you wanted one. Pasting both into a JSONPath tester and watching the matches highlight in place is far faster than adding a print statement and redeploying.
Below: what JSONPath actually is, the syntax that trips people up, and a set of query examples you can run against a real payload.
What Is JSONPath, and Why Test JSONPath Expressions Online
JSONPath is a query language for JSON, the same way XPath is a query language for XML. You write a path expression, it walks the document, and it returns every node that matches.
The basic building blocks are short:
$is the root of the document..keyselects a child by name.[0]selects an array element by index...searches recursively at any depth.[?(...)]filters by a condition.*is a wildcard for all children.
The reason to test JSONPath expressions online rather than in code is feedback speed. In a script, a wrong expression returns an empty list and you have no idea whether the path was wrong, the data was shaped differently than you assumed, or the filter comparison silently failed on a type mismatch. In a tester, the document sits right there with matches highlighted, so you can see immediately which of those three it was.
JSONPath vs XPath: Same Idea, Different Rules
If you already know XPath, most of JSONPath will feel familiar, but a few differences bite.
XPath has attributes and elements as distinct concepts. JSON has neither, only keys and values, so JSONPath drops the @attribute distinction entirely. The @ symbol in JSONPath means something different: it refers to the current node inside a filter expression.
XPath uses // for recursive descent. JSONPath uses .. for the same job.
XPath indexes arrays starting at 1. JSONPath indexes starting at 0, matching JavaScript and most programming languages. That off-by-one catches people migrating queries between the two.
XPath is a W3C standard with one specification. JSONPath is not, which means implementations differ in the edge cases. A filter that works in one library may behave differently in another. Worth knowing before you assume a query that passed in your tester will behave identically in your Java or Python runtime.
JSONPath Query Examples Against a Real API Response
Here is a payload to work against. It looks like a typical paginated API response.
{
"meta": { "page": 1, "total": 4 },
"data": [
{
"id": 101,
"name": "Wireless Mouse",
"price": 24.99,
"inStock": true,
"tags": ["accessories", "wireless"]
},
{
"id": 102,
"name": "Mechanical Keyboard",
"price": 89.00,
"inStock": false,
"tags": ["accessories", "input"]
},
{
"id": 103,
"name": "USB-C Hub",
"price": 45.50,
"inStock": true,
"tags": ["accessories", "connectivity"]
},
{
"id": 104,
"name": "Monitor Stand",
"price": 120.00,
"inStock": true,
"tags": ["desk"]
}
]
}
Now the queries, from simple to less simple:
$.meta.total
โ 4
$.data[0].name
โ "Wireless Mouse"
$.data[*].name
โ ["Wireless Mouse", "Mechanical Keyboard", "USB-C Hub", "Monitor Stand"]
$.data[?(@.inStock == true)].id
โ [101, 103, 104]
$.data[?(@.price < 50)].name
โ ["Wireless Mouse", "USB-C Hub"]
$..tags
โ [["accessories","wireless"], ["accessories","input"], ["accessories","connectivity"], ["desk"]]
$.data[0:2].name
โ ["Wireless Mouse", "Mechanical Keyboard"]
Two of those deserve a closer look.
The filter [?(@.price < 50)] uses @ to mean "the current item being tested." JSONPath checks each object in data against the condition and returns only the matches. That is the single most useful construct in JSONPath and the one most worth practicing in a tester.
The slice [0:2] follows Python conventions: start inclusive, end exclusive. It returns elements 0 and 1, not 0 through 2. Getting that wrong by one element is a classic bug.
How to Test JSONPath Queries Without Guessing
A workflow that avoids the usual dead ends:
Start at the root and walk down one level at a time. Run $.data first and confirm you get an array. Then $.data[0], then $.data[0].price. When a longer expression returns nothing, the shortest failing prefix tells you exactly where your assumption about the structure broke.
Check your types before writing a filter. A comparison like @.price < 50 fails silently if price is the string "45.50" rather than the number 45.50. The tester shows you the raw value, quotes and all.
Use recursive descent when you do not know the depth. If a field sits buried somewhere in a deeply nested response and you are not sure where, $..fieldName finds every occurrence at any level. Once you see where it actually lives, replace it with an explicit path, which is faster and less fragile.
Confirm the match count, not just the shape. A query returning one object when you expected four usually means your filter is too narrow, not that the data is missing.
If the response you are testing arrives minified as a single line, run it through the JSON Formatter first. Indented JSON makes the structure legible, and the formatter validates syntax at the same time, ruling out a malformed payload as the cause of a failing query.
A JSONPath Syntax Cheat Sheet Worth Keeping
| Expression | Meaning |
|---|---|
$ |
Root object |
$.store |
Child key named store |
$['store'] |
Same, bracket notation for keys with spaces or dashes |
$..author |
All author keys at any depth |
$.store.book[*] |
Every element in the book array |
$.book[0] |
First element |
$.book[-1] |
Last element |
$.book[0:3] |
Elements 0, 1, 2 |
$.book[?(@.price < 10)] |
Elements matching a condition |
$.book[?(@.isbn)] |
Elements where isbn exists |
$..* |
Every node in the document |
Bracket notation matters more than it looks. You cannot write a key like content-type or user id as $.content-type, because the parser reads the hyphen as an operator. Use $['content-type'] instead.
Keeping Response Data Private While You Test JSONPath Expressions Online
API responses carry things you should not paste into a random server: bearer tokens, internal endpoints, customer email addresses, session identifiers.
The Toolblip JSON Path Tester evaluates expressions entirely in your browser. JavaScript on your own machine parses your payload, and it never leaves.
Verify that in about fifteen seconds:
- Open the JSON Path Tester.
- Switch to the Network tab in your browser DevTools.
- Clear the request list.
- Paste a payload, type an expression, and watch the matches appear.
The Network tab stays empty. No POST fires, no request body carries your data anywhere. Any tool that claims client-side evaluation but shows a request at the moment you hit run is not doing what it says, and you should stop feeding it production payloads.
Run that check once per tool. It is faster than reading a privacy policy and gives a far more direct answer.
Where a Free JSONPath Online Tool Fits Your Workflow
Writing an API integration test. Assert on a specific field deep in a response without hardcoding array positions that shift between runs.
Configuring a monitoring alert. Many alerting systems accept a JSONPath expression to pull a metric out of a health check response. Getting the expression right before you save the config avoids an alert that silently never fires.
Building a data extraction step. Tools like Postman, Kubernetes kubectl, and various CI systems all accept JSONPath. Testing the expression against a real sample first beats debugging it inside a pipeline.
Exploring an unfamiliar API. Run $..* against a response you have never seen and you get a full inventory of every node, which is a fast way to learn the shape.
For related validation work, a Regex Tester handles the cases where you need to check value formats rather than locate them, and the Base64 Encoder and Decoder helps when a JSONPath query lands on a field holding an encoded blob you need to read before going further.
Test JSONPath Expressions Online Now
JSONPath is a small language, and most of the difficulty comes from writing an expression blind against data you cannot see. A tester removes that. Paste the payload, type the query, watch what lights up, adjust.
Ten seconds of that loop replaces a redeploy cycle.
Open the JSON Path Tester on Toolblip and test JSONPath expressions online right now. Free, no signup, and it runs entirely in your browser.
Ready to try it yourself?
Browse Free Tools โ