About JSONPath Tester
Test JSONPath queries against your JSON live. Wildcards, array slicing, recursive descent, filter expressions — all supported. Each match shows its path and value, and the matched substrings highlight in the source for visual confirmation. Useful when extracting data from large API responses without writing code.
What JSONPath gives you
A way to extract values from a JSON document by path, without writing code. The syntax is dense but learnable in 20 minutes:
| Expression | Meaning |
|---|---|
$ | The root |
.foo or ['foo'] | Property foo |
[0], [-1] | Array index (negative counts from end) |
[0:5] | Array slice |
* | All elements |
..foo | Recursive descent — every foo at any depth |
[?(@.age > 18)] | Filter — items where the condition holds |
[1, 3, 5] | Specific indices |
How to use the tester
- Paste JSON in the upper pane.
- Type a JSONPath query in the input.
- Watch matches appear in the result panel; each result shows the resolved path and value.
- Click a result to highlight the source location.
Common workflows
Extract from a large API response. A 5 MB response with the data you need three levels deep. $.data.items[?(@.status == 'active')].id pulls just the IDs.
Verify a webhook payload contains expected fields. $.event.user.email returns the email if present, empty otherwise. Quick sanity check before writing the parser.
Map fields for an ETL. Find the path to each desired field, write them down, transcribe to your transformation code.
Build assertions for tests. A test that says expect($.user.id).toBe('123') is more readable than walking the object manually. Some test runners accept JSONPath directly.
JSONPath in kubectl and Kubernetes
kubectl ships a built-in JSONPath output format for reading fields out of cluster objects without piping through jq:
kubectl get pods -o jsonpath='{.items[0].metadata.name}'
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}'
Kubernetes’ implementation has quirks: the leading $ is optional, you wrap the whole expression in {}, and it uses range/end for iteration with custom separators. It does not support filters as richly as RFC 9535, so test the shape of your data here first, then translate to the {} syntax. Ranges look like:
kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.phase}{"\n"}{end}'
JSONPath in Python, Java, and RestAssured
Once a path works in the tester, drop it into code:
- Python —
pip install jsonpath-ng, thenparse("$.store.book[*].author").find(data)returns match objects; read.valueoff each.jsonpath_ngis the maintained fork most projects use. - Java (Jayway JsonPath) —
JsonPath.read(json, "$.store.book[-1].title"). UseConfigurationwithOption.DEFAULT_PATH_LEAF_TO_NULLwhen a leaf may be absent. - RestAssured — assert directly on a response body:
response.then().body("store.book[0].title", equalTo("..."))(note RestAssured uses Groovy GPath, close to JSONPath but not identical — brackets and filters differ).
Filter and where-condition examples
JSONPath’s [?(...)] is the “where” clause:
| Goal | Query |
|---|---|
| Where value equals | $.users[?(@.role == 'admin')] |
| Where numeric compare | $.items[?(@.price > 100)] |
| Multiple conditions | $.users[?(@.age > 18 && @.active == true)] |
| Field exists | $.users[?(@.email)] |
| Last element | $.purchases[-1] |
Why a tester beats a one-shot script
A throwaway script forces a context switch. The tester gives you immediate feedback — type, see results, iterate. Once the path is right, copy it into your real code. The same skill scales from one-off API debugging to production query writing.
Frequently asked questions
What is JSONPath?
$ is the root; dots traverse properties; brackets index arrays. Wildcards (*), recursive descent (..), and filters ([?(...)]) build expressive queries.How does it differ from JMESPath?
Can I use filter expressions?
$.users[?(@.age > 18)] selects all users older than 18. @ is the current element; standard comparisons (==, !=, <, >, <=, >=) and logical (&&, ||, !) work.What does <code>..</code> do?
$..price finds every property named price at any depth. Useful when the structure is nested and you do not want to write the full path.Can I extract multiple paths at once?
$..[?(@.id == 1 || @.id == 2)] with logical operators. For unrelated selections, run two queries and merge results in code.How do I get the last element of an array in JSONPath?
$.purchases[-1] returns the last element, $.purchases[-2] the second-to-last. Negative indexing counts from the end and is supported by this tester and by most libraries (Python jsonpath-ng, Jayway JsonPath). If a library predates RFC 9535 and rejects [-1], use a slice like $.purchases[-1:] instead.What happens when a JSONPath is missing — can I set a default value?
DEFAULT_PATH_LEAF_TO_NULL and SUPPRESS_EXCEPTIONS options, and Python jsonpath-ng returns an empty list you can coalesce with or default. This tester simply shows zero matches so you can confirm the path before wiring in a default.Is the query running in my browser?
Related tools
Last updated: 2026-07-04