JSONPath Examples, Syntax & Query Playground
Learn JSONPath with real examples. Test expressions instantly against live JSON data. Explore arrays, filters, recursive queries, and Kubernetes JSONPath.
Interactive JSONPath Playground
Enter JSON and a JSONPath expression,
then click Run Query
JSONPath Syntax Cheat Sheet
| Syntax | Name | Description |
|---|---|---|
| $ | Root | The root object or array |
| .property | Dot notation | Child operator — access a property |
| ['property'] | Bracket notation | Alternative property access (quoted) |
| [0] | Array index | Access element by zero-based index |
| [*] | Wildcard | All elements in an array |
| [0,1,2] | Union | Select multiple specific indices |
| [0:5] | Slice | Range of elements (start:end) |
| [0:5:2] | Slice with step | Range with step increment |
| .. | Recursive descent | Deep search at any nesting level |
| ?() | Filter | Filter elements by condition |
| @ | Current node | References current item in a filter |
| ==, !=, <, > | Comparison ops | Compare values in filters |
| &&, || | Logic ops | Combine conditions (AND, OR) |
| {.items[*]} | Kubernetes style | Wrap with {} for kubectl output |
JSONPath Examples Library
{
"user": {
"name": "Tom",
"age": 30,
"active": true
}
}$.user.name"Tom"{
"order": {
"customer": {
"name": "Alice",
"email": "alice@example.com"
},
"total": 49.99
}
}$.order.customer.email"alice@example.com"{
"user-info": {
"first-name": "Bob"
}
}$['user-info']['first-name']"Bob"AI Explain JSONPath
Understand any JSONPath in plain EnglishCommon JSONPath Mistakes
Missing root symbol $
Problem: Writing `.store.book` instead of `$.store.book`
Fix: Always start your JSONPath expression with `$` to indicate the root of the document. The only exception is the `@` symbol used inside filter expressions.
Incorrect array index
Problem: Using 1-based indexing like `$.users[1]` expecting the first element
Fix: JSONPath uses zero-based indexing. `$.users[0]` returns the first element, `$.users[1]` returns the second.
Filter syntax errors
Problem: Forgetting `@` in filters, e.g., `$.users[?(.age > 18)]`
Fix: Always use `@` to reference the current item inside a filter: `$.users[?(@.age > 18)]`.
Recursive query confusion
Problem: Expecting `$..name` to only match direct children
Fix: Recursive descent (`..`) searches ALL levels. `$..name` matches the `name` field at any depth in the JSON document. Use `$.name` if you only want the top-level field.
String comparison in filters
Problem: Using unquoted strings like `$.users[?(@.role == admin)]`
Fix: String values in filter expressions must be quoted: `$.users[?(@.role == 'admin')]`.
Kubernetes curly brace scope
Problem: Forgetting `{}` when using kubectl, or using them where not needed
Fix: Kubernetes requires wrapping JSONPath in `{}` for kubectl commands. For non-Kubernetes use, the curly braces are not standard JSONPath and may cause errors.
JSONPath FAQ
What is JSONPath?
JSONPath is a query language for navigating and extracting data from JSON documents. Think of it as XPath for JSON — it lets you address specific parts of a JSON structure using path expressions like $.store.book[0].title.
How do I query arrays with JSONPath?
Use bracket notation to access array elements. $[*] returns all elements, $[0] returns the first element, and $[0:3] returns a slice. Combine with dot notation to access nested properties: $.users[*].name gets all user names.
How do I use filters in JSONPath?
Filters use the ?() syntax: $[?(@.price < 20)] filters items where price is less than 20. The @ symbol represents the current item being evaluated. You can use comparison operators (==, !=, <, >, <=, >=) and logical operators (&&, ||).
How do I filter with multiple conditions?
Use && (AND) and || (OR) inside filter expressions. For example, $.users[?(@.age > 18 && @.active == true)] matches users older than 18 who are active. $.users[?(@.role == 'admin' || @.role == 'editor')] matches admins OR editors.
How do I search tags in JSONPath?
Use bracket indexing or wildcards on tag arrays. $.products[?(@.tags[0]=='tech')] matches products whose first tag is 'tech'. $.products[?(@.tags[*]=='mobile')] matches products where any tag equals 'mobile'. For multiple tags: $.products[?(@.tags[*]=='tech' && @.tags[*]=='mobile')].
How do I use JSONPath with kubectl?
Kubernetes uses a slightly different syntax: wrap the expression in curly braces, e.g., {.items[*].metadata.name}. This returns all pod names from a kubectl JSON output. Use {.items[*].status.podIP} to get all pod IPs.
What is the difference between JSONPath and JSON Pointer?
JSONPath is a query language that can return multiple values, supports filters, wildcards, and recursive descent. JSON Pointer (RFC 6901) is simpler — it only points to a single location using /-separated paths. JSONPath is better for querying; JSON Pointer is better for referencing specific nodes.
JSONPath — the complete guide to querying JSON
JSONPath is the standard query language for JSON documents — like XPath for XML. Whether you're extracting data from APIs, automating kubectl commands, or building data pipelines, JSONPath gives you precise control over which values to retrieve. FormatList's JSONPath playground lets you learn syntax, test expressions, and see results instantly.
Why learn JSONPath?
- API testing — Extract specific fields from large API responses without writing scripts.
- Kubernetes — Use
kubectl get -o jsonpath=...to filter pod info, IPs, and names. - Data pipelines — Map JSON fields in ETL tools that support JSONPath expressions.
- Configuration management — Reference values in JSON config files with precise path expressions.
What you'll find on this page
- Interactive Playground — Paste JSON, write JSONPath, see results instantly.
- Syntax Cheat Sheet — Quick reference for all JSONPath operators.
- Examples Library — Ready-to-run examples organized by category: Basic, Arrays, Filters, Multiple Conditions, Tags, Recursive, and Kubernetes.
- AI JSONPath Explainer — Type any expression to get a plain-English explanation.
- Common Mistakes — Avoid the most frequent JSONPath pitfalls.