JSONPath
ExpressionResults are always returned as an array
JSON Input
Loading editor…
Results
Loading editor…

JSONPath Query Tool

Paste your JSON on the left, write a JSONPath expression, and see matching results instantly on the right. Great for exploring API responses, extracting nested values, and testing queries before using them in code.

Real-time
Results update as you type.
Full syntax
Supports filters, wildcards, recursion.
Match count
Shows how many results matched.
Copy
Copy results to clipboard.

Common JSONPath Expressions

JSONPath uses $ to represent the root of the document. Here are the most useful patterns:

ExpressionMeaning
$Root element
$.nameField name on the root object
$.users[0]First element of users array
$.users[*]All elements of users array
$.users[*].emailemail field from every user
$..nameAll name fields at any depth (recursive)
$.users[?(@.active == true)]Filter: users where active is true
$.items[?(@.price < 10)]Filter: items where price is less than 10

JSONPath Syntax in Depth

Dot notation vs bracket notation — both forms are equivalent:

  • $.user.name is the same as $['user']['name']
  • Bracket notation is required when a key contains spaces or special characters: $['first name']

Array slicing — Python-style slice syntax selects a range of elements:

  • $.items[0:3] — first three items (indices 0, 1, 2)
  • $.items[-1:] — last item
  • $.items[::2] — every second item

Union — select multiple fields or indices in one expression:

  • $.user['name','email'] — both name and email fields
  • $.items[0,2,4] — items at index 0, 2, and 4

Filter expressions — use @ to refer to the current node:

  • $.users[?(@.age >= 18)] — users who are adults
  • $.products[?(@.stock > 0 && @.price < 50)] — in-stock items under $50
  • $.users[?(@.role == 'admin')] — users with admin role

Recursive descent$.. searches all depths:

  • $..id — every id field anywhere in the document
  • $..price — useful for finding all prices in a nested product catalogue

Where JSONPath Is Used

Postman test scripts use JSONPath to assert values in API responses:

pm.expect(pm.response.json().data.users[0].name).to.equal("Alice");

AWS Step Functions use JSONPath for InputPath, OutputPath, and ResultPath — the mechanism that extracts and routes data between states in a state machine.

kubectl supports JSONPath via the -o jsonpath flag for formatting command output:

kubectl get pods -o jsonpath='{.items[*].metadata.name}'

Splunk's spath command extracts fields from JSON events using JSONPath-like expressions. Spring Boot's MockMvc and REST Assured both use JSONPath for response body assertions in integration tests.

JSONPath vs jq

JSONPath and jq solve similar problems but in different contexts.

FeatureJSONPathjq
Primary useEmbedded in tools (Postman, AWS, K8s)Command-line JSON processing
Syntax$.users[?(@.active)]`.users[]
Output transformationRead-only extractionFull transformation (map, reduce, format)
InstallationNone — built into many toolsRequires installation
Learning curveLowMedium

JSONPath is the right choice when writing expressions inside another tool — Postman tests, AWS state machines, Kubernetes output flags, or Spring test assertions. jq is the right choice on the command line when you need to transform or reshape data, not just extract a value from it.

Frequently Asked Questions

What is JSONPath?

JSONPath is a query language for JSON, similar to XPath for XML. It lets you extract specific values from a JSON document using a path expression. It is widely used in tools like Postman, AWS Step Functions, and Kubernetes.

What does `$` mean in a JSONPath expression?

The $ symbol represents the root of the JSON document. All JSONPath expressions start with $. For example, $.name selects the name field at the top level.

How do I select all items in an array?

Use the wildcard [*]. For example, $.users[*] returns all elements in the users array, and $.users[*].name returns the name field from every user.

How do I filter results by a condition?

Use a filter expression: $.users[?(@.active == true)]. The @ symbol refers to the current element being evaluated. You can use ==, !=, <, >, <=, >= operators.

What is the `..` (recursive descent) operator?

The .. operator searches all levels of the document. For example, $..email returns every email field regardless of how deeply nested it is.

What is the difference between dot notation and bracket notation?

They are equivalent for simple keys — $.user.name and $['user']['name'] return the same result. Bracket notation is required when a key contains spaces, hyphens, or other special characters that dot notation cannot express.

Can JSONPath modify or update JSON?

No. JSONPath is a read-only query language — it can only select and extract values. To modify JSON you need to use code (JavaScript, Python, etc.) or a tool like jq.

Is my JSON data uploaded anywhere?

No. JSONPath evaluation runs entirely in the browser tab. No data is transmitted.

More Tools