JSONPath Tester: How to Query JSON with JSONPath Expressions

Multi-Toolkit Team7 min read
Developer ToolsJSONQuery Language

JSONPath is to JSON what XPath is to XML — a query language for extracting values from a nested document using a path expression. Instead of writing nested loops or chaining obj.a.b.c accesses, a single JSONPath expression can extract all prices, all user IDs, or all error messages from any JSON structure, no matter how deeply nested.

JSONPath syntax reference

The root of any document is $. From there, dot notation navigates keys and bracket notation navigates arrays:

$.store.book[0].title        // first book title
$.store.book[*].title        // all book titles (wildcard)
$..price                     // all prices anywhere in the document
$.store.book[?(@.price < 10)] // books cheaper than $10 (filter)
$.store.book[-1:]            // last book (slice notation)
$.store.*                    // all values under "store"

Key operators

  • $ — root element
  • . or ['key'] — child property access
  • .. — recursive descent (searches all descendants)
  • * — wildcard (all properties or array elements)
  • [n] — array index (0-based); negative counts from end
  • [start:end:step] — array slice (Python-style)
  • [?(@.key op value)] — filter expression (@ is current node)

Filter expressions in detail

Filter expressions use [?()] with @ representing the current array element. Supported comparison operators: ==, !=, <, <=, >, >=. You can also check for key existence: [?(@.discount)] returns elements that have a discount field, regardless of its value.

// All users with role "admin"
$.users[?(@.role == "admin")]

// All orders with total over 100
$.orders[?(@.total > 100)]

// Items with a "sale" property present
$.items[?(@.sale)]

JSONPath vs jq

JSONPath is simpler and more portable — it is natively supported in most backend frameworks and API gateways (Elasticsearch, AWS Step Functions, Postman, etc.). jq is more powerful (it is a full transformation language) but requires installation and has its own syntax. For querying and extracting values without transformation, JSONPath is the right tool. For reshaping, aggregating, or computing derived values, jq wins.

Test any JSONPath expression against your JSON instantly — real-time results:

Test JSONPath expressions →

← Back to all articles