JSONPath Tester

Test JSONPath expressions against JSON data. Supports dot notation, wildcards, recursive descent, array slices, and filter expressions — all in the browser.

Examples:
[ "Sayings of the Century", "Sword of Honour", "Moby Dick", "The Lord of the Rings" ]
4 matches

JSONPath Syntax Reference

ExpressionDescription
$Root of the document
$.keyAccess property 'key' on root object
$.a.b.cNested property access
$['key']Bracket notation property access
$.*All direct children of root
$.arr[*]All elements of array 'arr'
$.arr[0]First element of array
$.arr[-1]Last element of array
$.arr[0,2]Elements at index 0 and 2
$.arr[1:3]Slice: elements at index 1 and 2 (end exclusive)
$..keyRecursive descent — find 'key' at any depth
$.arr[?(@.x > 5)]Filter: elements where x > 5
$.arr[?(@.name == 'foo')]Filter: elements where name equals 'foo'

JSONPath Filter Expressions

Filter expressions let you select array elements based on conditions. The syntax is [?(@.field operator value)] where @ refers to the current element being evaluated. Supported operators are ==, !=, >, <, >=, and <=.

Examples using the default book store JSON:

  • $.store.book[?(@.price < 10)] — books cheaper than $10
  • $.store.book[?(@.category == "fiction")] — fiction books only
  • $.store.book[?(@.price >= 12)].title — titles of books costing $12 or more

JSONPath vs jq

JSONPath and jq both query JSON, but they serve different use cases. JSONPath is a declarative path language — it describes where data lives. It's supported in REST APIs (AWS Step Functions, Kubernetes JSONPath in kubectl), testing frameworks (REST Assured, Postman), and configuration systems.

jq is a full transformation language. In addition to selecting data, it can reshape it, compute values, apply conditionals, iterate, and format output. jq is the right choice when you need to transform JSON on the command line. JSONPath is the right choice when you need to extract data using a compact, readable expression in a library or API.

FeatureJSONPathjq
Primary useQuery / extractQuery + transform
FormatPath expressionFull scripting language
CLI toolNoYes (brew install jq)
Library supportMany languagesBindings available
Data reshapingNoYes
Filter supportBasic (==, !=, <, >)Full expressions
Where it's usedKubernetes, AWS, PostmanCommand line, CI/CD

Frequently Asked Questions

What is JSONPath?

JSONPath is a query language for JSON, analogous to XPath for XML. It lets you extract specific values from a JSON document using a path expression that describes the location of the target data. For example, $.store.book[*].title extracts all book titles from a store object. JSONPath was originally proposed by Stefan Goessner in 2007 and is widely used in APIs, test assertions, and configuration systems.

What is the difference between JSONPath and jq?

JSONPath is a standardized query language specifically for navigating JSON structures, while jq is a full command-line JSON processor that supports filtering, mapping, transformation, and more. JSONPath is supported natively in many languages and tools (AWS, Kubernetes, Postman, REST Assured), whereas jq is primarily a CLI tool. For simple read queries like extracting fields or filtering arrays, JSONPath is often sufficient. For complex transformations, jq is more powerful.

How do filter expressions work in JSONPath?

Filter expressions are written as [?(@.field operator value)] and applied to arrays. The @ refers to the current element being tested. For example, $.store.book[?(@.price < 10)] returns all books with a price under 10. Supported comparison operators are == (equals), != (not equals), < (less than), > (greater than), <= (less than or equal), and >= (greater than or equal). String values in filter expressions should be quoted.

What does .. (recursive descent) do in JSONPath?

The .. operator (recursive descent or deep scan) searches the entire JSON document at any depth for the specified key. For example, $..author returns all 'author' values found anywhere in the document, whether they are nested one level deep or ten levels deep. This is particularly useful when you don't know the exact structure of a document and want to extract all instances of a given field.

How do I use JSONPath in JavaScript?

There is no built-in JSONPath support in JavaScript, but several libraries implement it — jsonpath-plus and jsonpath are popular npm packages. For simple cases, you can write your own evaluator (as this tool does). In Node.js, after npm install jsonpath-plus, use: const jp = require('jsonpath-plus'); const result = jp.query(data, '$.store.book[*].title'). The expression syntax is consistent across most implementations, though edge cases may vary.