04 / Testing / jsonpath-tester
JSONPath Tester
Evaluate JSONPath expressions against JSON.
How to use
- 01Type a JSONPath expression in the JSONPath expression field, starting with $ (for example $.store.users[*].name).
- 02Or click one of the example chips, such as $..price or $.store.items[?(@.price > 20)], to load a ready-made query.
- 03Paste the JSON you want to query into the JSON editor; a sample store document is preloaded.
- 04Read the Matches panel, which re-evaluates on every keystroke and shows the result count and every match as a JSON array.
- 05Press Copy matches to copy the result array, or Clear JSON to start over with your own payload.
What is this tool?
A live JSONPath tester for querying API responses and JSON fixtures. It supports dot and bracket notation, wildcards, recursive descent, array indexes, negative indexes, unions, slices, filter expressions with comparison and regex operators, and a trailing .length. Invalid JSON and invalid JSONPath are reported separately so you know which side to fix, and everything is evaluated locally in your browser.
JSONPath syntax cheat sheet
Every expression starts at the root, $. Use .key or ['key'] to step into an object, [0] for an array index, [-1] for the last element, [0,2] for a union of indexes and ['id','name'] for several keys at once. [*] or .* returns every child, and .. performs a recursive descent, so $..price collects every price field at any depth. Slices use [start:end] with the end excluded, so $.store.users[-1:] returns the last user and [0:2] returns the first two.
Filters select array items (or object values) by a condition on the current item, written as @. This tester supports ==, !=, >, <, >= and <= against numbers, quoted strings, true, false and null, plus =~ with a /regex/flags literal. A filter with no operator, such as [?(@.email)], keeps items where the field exists. Nested fields work inside filters, for example [?(@.address.city == 'Austin')].
Worked example: against the preloaded sample, $.store.items[?(@.price > 20)] returns the single item with sku B2, $.store.users[?(@.active == true)].name returns ["John"], and $.store.users[*].roles.length returns the length of each roles array, [1, 1].
Common reasons a JSONPath returns no results
Comparisons are strict. If the API returns "id": "42" as a string, [?(@.id == 42)] will not match; write [?(@.id == '42')] instead. The same applies to booleans sent as strings. Check the raw response before blaming the expression.
The result is always an array, even for a single value. Tools like REST Assured, Postman and Karate differ in whether they unwrap single matches, so a path that returns ["John"] here may surface as "John" in your test framework. Also note that this tester does not support compound filters with && or ||, script expressions, or functions beyond the trailing .length, so keep conditions to a single comparison and chain filters by path when you need to narrow further.
Using JSONPath in API test automation
JSONPath is how most API test tools reach into a response body. Postman scripts usually navigate with JavaScript property access, while REST Assured uses GPath and Karate, Jayway-based Java suites and many CI assertion plugins accept JSONPath directly. Prototyping the expression against a real response here first means your assertion fails for the right reason, not because of a typo in the path.
Once an expression works, you can use the same path in the API Assertions tool or the Assertions tab of the API Testing Workbench, which run JSONPath exists, equals, greater-than and less-than checks with this same evaluator.
Common use cases
- Writing JSONPath assertions for Karate or Jayway-based REST API tests
- Extracting an ID or token from a response to chain into the next request
- Checking that a filter selects exactly the records a test expects
- Exploring a large, unfamiliar API response with recursive descent
- Debugging why an extraction step in a CI pipeline returns an empty array
FAQ
How do I test a JSONPath expression online?
Paste your JSON into the JSON editor and type the expression in the JSONPath expression field. Matches update as you type, along with a result count.
Does this JSONPath tester support filter expressions?
Yes. Filters like [?(@.price > 20)] support ==, !=, >, <, >=, <=, an existence check such as [?(@.email)], and regex matching with =~ /pattern/flags. Combining conditions with && or || is not supported.
How do I get the length of an array with JSONPath?
Append .length to the path, for example $.store.items.length. It works for arrays and strings.
What does $.. mean in JSONPath?
It is recursive descent: $..price finds every price key anywhere in the document, regardless of nesting depth.
Why does my expression say JSONPath must start with $?
Every expression must begin at the root symbol $. Write $.user.id rather than user.id or @.user.id.
Is my JSON sent to a server?
No. Parsing and JSONPath evaluation happen entirely in your browser.