Skip to content

JSONPath Tester

Common patterns

Matches

Loading parser…

Estimates for educational purposes — not financial, medical, or legal advice. See terms.

JSONPath is to JSON what XPath is to XML — a small expression language for selecting nodes from a structured document without writing code to walk it. It’s the right tool when you’re prototyping a webhook handler, exploring an unfamiliar API response, or extracting a few fields from a config file for a one-off script.

How it works

A JSONPath expression is a series of steps that filter a tree of values:

  • $ — the root of the document
  • .foo or ['foo'] — child by name
  • [0] — child by index
  • [*] — all children at this level
  • .. — recursive descent (every descendant)
  • [?(...)] — predicate filter
  • [start:end] — slice (with negative indices and step support)

The tester evaluates expressions with jsonpath-plus, which implements the most-widely-deployed JSONPath dialect. Each match comes back with its canonical bracket-notation path so you can copy paths verbatim into other tools.

Example: extracting all author names from a bookstore

JSON:

{
  "store": {
    "book": [
      { "author": "Nigel Rees", "title": "Sayings of the Century" },
      { "author": "Evelyn Waugh", "title": "Sword of Honour" }
    ]
  }
}

Path: $..author (recursive descent finds every key named author).

Result: "Nigel Rees", "Evelyn Waugh" — each with its path: $['store']['book'][0]['author'], $['store']['book'][1]['author'].

Example: filtering by price

Path: $.store.book[?(@.price < 10)] — books cheaper than $10. Only the matching book objects are returned (full objects, not just one field).

Combine with field access: $.store.book[?(@.price < 10)].title — just the titles of cheap books.

Example: getting the last item of an array

Path: $.store.book[-1:] — slice from the second-to-last position. Returns the last book. Equivalent: $.store.book[(@.length-1)].

When JSONPath is the right tool

  • Quick API exploration — paste a response, find the field you need without writing parser code.
  • Webhook payload extraction — many automation platforms (Zapier, n8n, Make, Pipedream) use JSONPath as the field-picker syntax.
  • Config inspection — pull values from Kubernetes manifests, Terraform plans, package.json files.
  • Test fixture queries — assert on specific paths in API integration tests.

When to use something else

  • Schema validation — JSONPath only finds nodes; it doesn’t validate types or required fields. Use JSON Schema for that.
  • Mutation — JSONPath is read-only. To modify JSON in-place, use jsonpath-plus’s callback API (programmatically, not in this tester) or a library like jsonpatch.
  • Heavy transformations — chain JSONPath outputs into a real script. JSONPath is for selection, not transformation.

Common gotchas

Quotes. Use single quotes inside filter expressions for string literals: ?(@.category === 'fiction'). Double quotes inside a JSONPath expression that’s already enclosed in double quotes (in source code) require escaping — single quotes sidestep the issue.

.. performance. Recursive descent visits every node in the tree. For huge documents (10k+ nodes) it can be slow. Anchor your path to a known prefix ($.store..price instead of $..price) when you can.

@ only works inside filters. @ refers to the current node during predicate evaluation. It’s an error outside ?(...).

Index-based vs slice notation. $.book[0] returns one item; $.book[0:1] returns a one-element array containing that item. Slices always return arrays; single indices return single values.

If the JSON you’re testing against is unformatted, the JSON formatter & validator will pretty-print it first; for pattern-based search inside JSON string values, the regex tester is the complementary tool.

Frequently asked questions

Which JSONPath flavour is this?

Stefan Goessner's original 2007 specification, plus the `?(@.field op value)` filter expression extension that all major implementations support. Built on jsonpath-plus, which is the most-deployed JavaScript JSONPath library. Note that there's a draft IETF standard (RFC 9535, published 2024) that tightens some semantics — particularly around `==` vs `===` in filters and how `..` interacts with object roots. jsonpath-plus mostly conforms to the IETF draft but predates it; differences are edge-case and unlikely to affect everyday queries.

Why is the parser only loaded when I interact?

Because jsonpath-plus is ~15 KB gzipped, and most visitors land on this page to read documentation, not to actually run a query. Loading the parser only when you paste/edit means the page itself stays fast and lighthouse-scores well. The first interaction has a ~50ms one-time cost; everything after that is instant. Net win for SEO and for users who don't need the tool.

What's the difference between `$..foo` and `$.*.foo`?

`$..foo` (recursive descent) finds every property named `foo` at any depth — through arrays, through nested objects, anywhere. `$.*.foo` matches `foo` only one level below the root. So in `{a: {foo: 1}, b: {c: {foo: 2}}}`, the recursive form returns both 1 and 2; the wildcard form returns only 1. Use recursive descent when you don't know the depth; use wildcards when you want a specific level.

How do filter expressions work?

`?(...)` introduces a predicate evaluated against each candidate node. `@` refers to the current node. So `$.store.book[?(@.price < 10)]` walks every book in `$.store.book` and keeps the ones where `price` is less than 10. The expression is JavaScript-flavored: `==`, `===`, `!=`, `<`, `>`, `&&`, `||`, `!`, plus `match()` for regex, `subsetof()` for array containment, etc. Use single quotes for string literals (`'reference'`) inside the filter — double quotes will break out of the JSONPath string.

What if my JSON has a key that contains dots or special characters?

Use bracket notation with quotes: `$['my.weird.key']`. Dot notation only works for ASCII identifier-style keys (letters, digits, underscores, no leading digit). Bracket notation also works for indices (`$.book[0]` and `$['book'][0]` are equivalent) and is the canonical form for paths that the tool returns — every match comes back with `$['store']['book'][0]['title']`-style normalised path so you can copy it.