What JSONPath is
JSONPath is to JSON what XPath is to XML — an expression language for selecting specific values from a structured document. The most-cited reference is Stefan Goessner's original 2007 proposal; in 2024 it was standardized as RFC 9535. Expressions like $.store.book[*].title select "the title of every book in the store"; $..author finds every author field at any depth.
This tool runs JSONPath entirely in your browser using jsonpath-plus — the most widely-used JavaScript implementation. Paste your JSON, write an expression, see exactly what gets selected. Useful for debugging API response transformations, designing filters before adding them to production code, and learning the syntax interactively.
Syntax cheat sheet
$ root $.foo child "foo" $['foo'] same (bracket form, needed for hyphens/spaces) $..foo "foo" at any depth (recursive descent) $.users[0] first element of "users" $.users[-1] last element $.users[*] all elements $.users[0,2] elements at index 0 and 2 $.users[1:4] slice — indices 1 to 3 $.users[?(@.age > 21)] filter — adult users (@ = current item) $..[?(@.active == true)] all "active" objects anywhere $..book.length size of any "book" array $..* every value (very verbose; rarely useful in production)
Practical uses
- API response shaping. Quick prototyping of "extract the third
shipments[].tracking_numberper order" before writing the code. - Postman / Hoppscotch tests. JSONPath is the standard syntax for assertions in REST clients. Designing the path here first saves trial-and-error in the test runner.
- JSON Schema with conditional validation. Some validators accept JSONPath in custom rules. Prove the path works before plugging it in.
- Log line extraction. When your logs are structured JSON, JSONPath filters can pull specific events:
$..errors[?(@.code == 503)]. - GraphQL query design. Not GraphQL syntax, but the same mental model — JSONPath helps you reason about what fields you actually need from a deep response before writing the GraphQL query.
- Configuration injection. Tools like Helm, Kustomize, and AWS CloudFormation use JSONPath-like expressions for parameter overrides. The exact syntax varies; this tool teaches the canonical version.
JSONPath vs JMESPath vs jq
Three popular query languages, overlapping use cases, different strengths:
- JSONPath (this tool) — most widely available across languages, best for selection. Limited transformation features. Standardized as RFC 9535.
- JMESPath — used by AWS CLI (
aws s3 ls --query "...") and several other AWS-related tools. More powerful filter syntax; standard typed return values. - jq — full programming language for JSON, with shell-pipeline ergonomics. The right tool when you need to reshape JSON, not just select from it.
jq '.users[] | select(.age > 21) | {id, email}'.
Rule of thumb: JSONPath for selecting fields from a known structure. JMESPath if you're already in the AWS ecosystem. jq for command-line JSON processing and any transformation more complex than "extract these fields".
Common pitfalls
- Implementation differences. Goessner's spec was loose, so historical implementations diverged on edge cases: how filter scripts evaluate, what happens with negative indices, behavior of
..on leaf nodes. RFC 9535 fixes this for new implementations but legacy libraries may differ.jsonpath-plusfollows the RFC closely. - Filter syntax with
@. Inside[?(...)],@refers to the current item being filtered. Don't confuse with$(root).$.users[?(@.age > $.threshold)]compares each user's age against a top-level threshold. - String quoting in filters. Use single quotes inside filter expressions:
$.users[?(@.role == 'admin')]. Some implementations also accept double quotes; sticking to single quotes avoids escape headaches in JS string literals. - Recursive descent is slow on huge documents.
$..fieldvisits every node. For documents with thousands of items, write a path that doesn't need recursion if you know the structure. - Empty result vs no-match. A JSONPath that matches nothing returns an empty array, not an error. Always check length before using
result[0].
Common use cases
- Design API response extractors before writing code
- Build Postman/Hoppscotch test assertions
- Debug structured log queries
- Learn JSONPath syntax interactively
Frequently asked questions
What does <code>$</code> mean? What does <code>@</code> mean?
<code>$</code> is the root of the document. <code>@</code> is the current item inside a filter expression. <code>$.users[?(@.age > 21)]</code> means "users where the current user's age > 21".
How do recursive descent (<code>..</code>) and wildcard (<code>*</code>) differ?
<code>$..foo</code> finds "foo" at any depth. <code>$.foo.*</code> selects all immediate children of foo (one level deep). Combine them: <code>$..book[*].author</code>.
JSONPath vs JMESPath vs jq?
JSONPath: most widely available, best for selection, standardized as RFC 9535. JMESPath: AWS's choice, more powerful filters. jq: full programming language for JSON, ideal for transformation. Use JSONPath for "extract these fields"; use jq for "reshape this data".
Why does my filter not match?
Most common cause: string-quoting. Inside filter expressions use single quotes (<code>@.role == 'admin'</code>), not double. Second cause: numeric vs string types — <code>@.id == '1'</code> doesn't match <code>"id": 1</code>.