JSONPath Query Tool
Execute JSONPath expressions and extract data from complex JSON structures. Our JSONPath tester helps you query and navigate through nested JSON data efficiently, making it perfect for data extraction, API response parsing, and JSON data manipulation.
Key Features:
- • Support for standard JSONPath expressions
- • Wildcard and array index operations
- • Real-time query execution
- • Multiple result visualization
- • Quick query templates for common patterns
JSONPath Query
Enter a JSONPath expression to query your JSON data
JSON Data
Your JSON data to query
Query Results
No results
📝 JSONPath Syntax
$ - Root element.property - Object property[0] - Array index[*] - All array elements.* - All object values💡 Examples
$.store.book[*].titleAll book titles$.store.book[0]First book object$..*All values recursivelyTry These Examples
Click any example to load it with a matching query
Bookstore (Classic)
The standard JSONPath example — books, prices, and a bicycle
$.store.book[*].titleAPI Response
Paginated user list — extract names, filter by role
$.data[*].nameNested Config
App configuration — navigate deeply nested settings
$.database.primary.host📚 Complete JSONPath Reference and Guide
What is JSONPath?
JSONPath is a query language for extracting data from JSON documents, similar to how XPath works for XML or CSS selectors work for HTML. Instead of writing loops and conditional logic to navigate nested JSON, you write a single expression like $.store.book[*].title and get back all matching values. JSONPath was originally proposed by Stefan Goessner in 2007 and has since been adopted across programming languages, testing frameworks, and data processing tools.
Our tool implements the core JSONPath specification: root access, dot and bracket notation, wildcards, and array indexing. Paste your JSON, write an expression, and see results instantly — all processing happens in your browser.
JSONPath Syntax Reference
Every JSONPath expression starts with $, which represents the root of the JSON document. From there, you chain operators to navigate deeper into the structure.
Operators
| Operator | Description | Example |
|---|---|---|
$ | Root element | $ — the entire document |
.key | Child property (dot notation) | $.store.name |
['key'] | Child property (bracket notation) | $['store']['name'] |
[n] | Array element by index (0-based) | $.books[0] — first book |
[*] | All elements in an array | $.books[*] — every book |
.* | All properties of an object | $.store.* — all store properties |
[start:end] | Array slice | $.books[0:3] — first three books |
.. | Recursive descent (deep scan) | $..price — all prices at any depth |
[?()] | Filter expression | $.books[?(@.price < 10)] |
JSONPath Examples with Sample Data
All examples below use this sample JSON document:
{
"store": {
"book": [
{"category": "reference", "author": "Nigel Rees",
"title": "Sayings of the Century", "price": 8.95},
{"category": "fiction", "author": "Evelyn Waugh",
"title": "Sword of Honour", "price": 12.99},
{"category": "fiction", "author": "Herman Melville",
"title": "Moby Dick", "price": 8.99},
{"category": "fiction", "author": "J.R.R. Tolkien",
"title": "The Lord of the Rings", "price": 22.99}
],
"bicycle": {"color": "red", "price": 19.95}
}
}Basic Property Access
$.store.bicycle.color → "red" $.store.book[0].title → "Sayings of the Century" $.store.book[2].author → "Herman Melville" $.store.book[0].price → 8.95
Wildcards — Get Multiple Values
$.store.book[*].title → ["Sayings of the Century", "Sword of Honour",
"Moby Dick", "The Lord of the Rings"]
$.store.book[*].price → [8.95, 12.99, 8.99, 22.99]
$.store.* → [book array, bicycle object]Array Slicing
$.store.book[0:2] → first two books (index 0 and 1) $.store.book[-1] → last book (The Lord of the Rings) $.store.book[1:3] → books at index 1 and 2
Recursive Descent — Search at Any Depth
$..price → [8.95, 12.99, 8.99, 22.99, 19.95]
(all prices — books AND bicycle)
$..author → ["Nigel Rees", "Evelyn Waugh",
"Herman Melville", "J.R.R. Tolkien"]Filter Expressions
$.store.book[?(@.price < 10)] → books with price under 10 (Sayings of the Century, Moby Dick) $.store.book[?(@.category == 'fiction')] → all fiction books $.store.book[?(@.price > 10 && @.category == 'fiction')] → fiction books over $10 (Sword of Honour, The Lord of the Rings)
JSONPath vs. jq: When to Use Which
Both JSONPath and jq extract data from JSON, but they serve different contexts and have different strengths:
| Feature | JSONPath | jq |
|---|---|---|
| Best for | Libraries, APIs, testing frameworks | Command-line processing, shell scripts |
| Data extraction | Strong — designed for querying | Strong — plus transformation |
| Data transformation | Limited — extraction only | Powerful — can reshape, filter, compute |
| Learning curve | Low — simple dot/bracket syntax | Medium — its own mini-language |
| Language support | Java, Python, JavaScript, PHP, C# | CLI tool (any language via shell) |
| Syntax example | $.store.book[*].title | .store.book[].title |
Use JSONPath when you are working inside application code (JavaScript, Python, Java) and need to extract values from JSON objects. Most languages have JSONPath libraries.
Use jq when you are working on the command line and need to process JSON from APIs, log files, or other CLI tools. jq is ideal for piping and shell scripting.
Using JSONPath in Your Code
JavaScript (jsonpath-plus)
import { JSONPath } from 'jsonpath-plus';
const data = { store: { book: [{ title: "Moby Dick", price: 8.99 }] } };
// Get all titles
const titles = JSONPath({ path: '$.store.book[*].title', json: data });
// → ["Moby Dick"]
// Get books under $10
const cheap = JSONPath({
path: '$.store.book[?(@.price < 10)]',
json: data
});Python (jsonpath-ng)
from jsonpath_ng.ext import parse # pip install jsonpath-ng
data = {"store": {"book": [{"title": "Moby Dick", "price": 8.99}]}}
# Get all titles
expr = parse("$.store.book[*].title")
titles = [match.value for match in expr.find(data)]
# → ["Moby Dick"]Command Line (jq equivalent)
# Get all book titles (jq equivalent of $.store.book[*].title) cat data.json | jq '.store.book[].title' # Get books under $10 cat data.json | jq '.store.book[] | select(.price < 10)' # Get just the prices as an array cat data.json | jq '[.store.book[].price]'
Real-World JSONPath Scenarios
Extracting Data from API Responses
Suppose you call a REST API that returns paginated user data:
// API response
{
"page": 1,
"total": 50,
"data": [
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"},
{"id": 3, "name": "Charlie", "role": "admin"}
]
}
// Get all names: $.data[*].name → ["Alice", "Bob", "Charlie"]
// Get all admins: $.data[?(@.role == 'admin')]
// Get first user ID: $.data[0].id → 1Querying Kubernetes Manifests
// Get all container images from a deployment $.spec.template.spec.containers[*].image // Get resource limits $.spec.template.spec.containers[*].resources.limits // Get all environment variable names $.spec.template.spec.containers[*].env[*].name
Parsing package.json Dependencies
// Get all dependency names $.dependencies.* → all dependency version strings $.scripts.* → all script commands
JSONPath Best Practices
- Start with the simplest path — get a basic expression working first, then add filters and wildcards. Build up complexity incrementally.
- Validate your JSON first — a JSONPath query on invalid JSON produces unpredictable results. Use our validator first.
- Use specific paths over recursive descent —
$.store.book[*].priceis faster and more predictable than$..price, especially on large documents. - Bracket notation for special characters — if a property name contains dots, spaces, or hyphens, use bracket notation:
$['my-key']instead of$.my-key. - Test with edge cases — check that your expression handles empty arrays, missing properties, and null values gracefully.
- Document complex expressions — if a JSONPath expression is longer than ~40 characters, add a comment explaining what it extracts and why.
- Consider performance — recursive descent (
..) and filter expressions ([?()]) scan the entire document. On large JSON (10MB+), prefer specific paths. - Remember array indices are 0-based —
$.books[1]is the second book, not the first. This is a common source of off-by-one bugs.
🔗 Related Tools & Resources
Explore these related JSON tools and guides