§

Test JSONPath expressions

Output format:
JSONPath quick reference
Token Meaning
$Root element of the document
@Current element (used inside filter expressions)
.Child member operator: selects a named child
..Recursive descent: searches all descendants
*Wildcard: matches any element or property
[*]All items of an array
[n]Array element at index n (zero-based)
[start:end]Array slice from start up to (not including) end
[?(@.x)]Filter: items where property x exists
[?(@.x==1)]Filter: items where property x equals 1
[(@.length-1)]Script expression: last element of an array

JSONPath shows up wherever an API contract has to be checked against a real payload. US fintech teams writing Postman regression suites assert response fields with JSONPath in the Test tab, k6 load-test scripts pull values out of API responses with jsonpath() to gate SLA thresholds inside check() blocks, and SRE on-call runbooks reach for filter expressions like [?(@.status=="error")] to slice CloudWatch JSON logs before paging. Running those expressions in a browser tab keeps proprietary fixture payloads, customer PII, and pre-release API responses off any hosted query service.

What is JSONPath?

JSONPath is a query language for JSON documents, the JSON equivalent of XPath for XML. Stefan Goessner proposed it in 2007 as a short, readable way to point at a node inside a JSON tree without writing a parser. An expression starts with the root selector $ and chains property accessors, array subscripts, wildcards, recursive descent, and filter conditions until it picks out the nodes you want. In 2024 the IETF published RFC 9535 to standardise the syntax that had fragmented across implementations; this tester runs on jsonpath-plus, a widely used JavaScript implementation that covers the Goessner draft, most of RFC 9535, and a few extension operators on top.

How JSONPath works

A JSONPath expression reads left to right and walks a JSON document one step at a time. Each step takes the set of nodes that survived the previous step and narrows it further. The full evaluation pipeline:

  1. Anchor with the root selector $. Every expression starts here, pointing at the top-level value, whether it's an object or an array. Bare property names without a leading $ are not valid JSONPath.
  2. Walk into child members with dot notation ($.store.book) or bracket notation ($['store']['book']). Bracket notation is required when a key contains a space, a hyphen, or any character that isn't a valid identifier.
  3. Search every level at once with the recursive descent operator ... The expression $..author collects every author value anywhere in the tree, regardless of depth. This is the operator JMESPath does not have.
  4. Pick array elements by index ([0], [-1] for the last item in jsonpath-plus), slice them with [start:end] notation ([0:3] returns the first three), or grab every element with the wildcard [*].
  5. Filter elements with a predicate inside [?(...)]. Inside the predicate, @ refers to the current element, so [?(@.price<10)] keeps only items whose price field is less than 10. Filters compose with the rest of the path, so you can filter then descend, or descend then filter.
  6. Pick the output format. Values returns the matched data itself. Paths returns the JSONPath of each match so you can see what the engine resolved. Pointers returns the equivalent RFC 6901 JSON Pointer for each match, useful when the downstream consumer is JSON Patch or a JSON Schema validator.

Why use this JSONPath tester?

  • Your JSON never leaves the browser. The query runs inside the page, so production fixtures, customer PII, and pre-release API responses stay on your machine.
  • The engine is jsonpath-plus 9.x, the same library that backs many production test suites and CI assertions. The results you see here match the results your build pipeline will see.
  • Three output modes cover the common downstream consumers: raw Values for copy-paste, Paths for debugging the engine's resolution, and RFC 6901 Pointers for JSON Patch and JSON Schema workflows.
  • Filter expressions run with preventEval: true, so a pasted query cannot execute arbitrary JavaScript against the host page. That matters when the expression came from a Slack message, a Jira ticket, or a colleague's clipboard.

Common applications of JSONPath

JSONPath shows up anywhere code has to pull a field out of a JSON payload without writing a recursive descent by hand:

  • Postman tests: the Tests tab in Postman exposes pm.response.json() together with JSONPath-style access for assertions. Teams write a single expression like $.data.user.email to pull a field out of a response and assert on it in CI.
  • k6 load tests: k6 scripts call jsonpath() inside a check() block to extract values from response bodies and assert SLA thresholds. The same expression that proved a contract in Postman can gate a load test under k6.
  • JSON DSL for data transforms: AWS Step Functions evaluates JSONPath inside InputPath, ResultPath, and Parameters to reshape event payloads between states. Argo Workflows uses JSONPath in withParam to fan-out tasks over an array. Kubernetes kubectl -o jsonpath uses the same syntax to extract fields from cluster objects.

Worked example

The canonical Goessner fixture is the book store document with four books, each carrying category, author, title, and price. Against that fixture, the expression $.store.book[?(@.price<10)].title runs in three steps. First, $.store.book resolves to the array of all four books. Next, the filter [?(@.price<10)] keeps only the one book priced below 10 (the entry at 8.95). Finally, .title extracts that book's title. The result is ["Sayings of the Century"]. Switching to Paths returns ["$['store']['book'][0]['title']"], and Pointers returns ["/store/book/0/title"].

Prototype your expressions here, then drop them straight into Postman, k6, kubectl, or a Step Functions state machine. Paste, query, copy. Nothing crosses the network.

What is JSONPath?

JSONPath is a query language for JSON documents, analogous to XPath for XML. Proposed by Stefan Goessner in 2007 and standardised by IETF as RFC 9535 in 2024.

It uses a compact expression syntax starting with $ (the document root) and supports dot notation, array subscripts, wildcards, slices, recursive descent (..), and filter expressions ([?(...)]) to select nodes inside a JSON tree.

How is JSONPath different from JMESPath or jq?

All three query JSON, but their grammars and goals differ. JMESPath is the AWS CLI / SDK standard: stricter than JSONPath, no recursive descent, built for predictable side-effect-free projection.

jq is a Turing-complete scripting language that not only queries JSON but transforms, reduces, and streams it. JSONPath sits between them: more expressive than JMESPath thanks to recursive descent and filters, lighter than jq, and the most widely supported syntax in general-purpose test tooling (Postman, Playwright, REST Assured, kubectl, Step Functions). This tester implements JSONPath.

What dialect does this tester use?

This tester runs jsonpath-plus 9.x. That library implements the Goessner 2007 spec, covers most of RFC 9535, and adds extension operators such as type checks (@.string(), @.number(), @.boolean()) and parent navigation (^).

The preventEval: true flag is always set, so filter predicates run through a safe interpreter rather than the JavaScript eval() built-in. A pasted query cannot execute arbitrary code against this page.

Can I copy individual matched values?

Yes. The Copy to clipboard button copies the full result block as a JSON array. To grab a single value, switch the output mode to Values, then select the line you want in the result textarea and use your browser's normal copy shortcut (Ctrl/Cmd + C).

The output is plain JSON text, so it pastes cleanly into a code editor, a terminal, a Postman test, or a Slack message.