Querying & Filtering • JSONPath Reference • 7 Min Read
JSONPath Syntax Guide: Filtering Expressions & Query Recipes
A reference manual and practical cheat sheet for navigating, querying, and filtering deeply nested JSON payloads.
Test your JSONPath expression interactively
Evaluate complex filters with instant visual node highlights in FormJson's console.
1. JSONPath Operators Cheat Sheet
| Symbol | Operator Name | Description & Example |
|---|---|---|
| $ | Root Element | Represents the root object or array: $ |
| @ | Current Node | The active item being processed inside a filter: [?(@.age > 21)] |
| .. | Recursive Descent | Finds keys anywhere in the hierarchy: $..author |
| * | Wildcard | Matches all keys or array elements: $.users.* |
| [start:end:step] | Array Slice | Python-style slice notation: $.items[0:5] (first 5 items) |
| [?()] | Filter Expression | Evaluates logical boolean expressions: $[?(@.active == true)] |
2. Production Query Recipes
Extract all emails from deeply nested user objects
$..email
Scans every object at any depth and returns a flat array of email values.
Find orders exceeding $500 with 'COMPLETED' status
$.orders[?(@.total > 500 && @.status == 'COMPLETED')]
Combines relational comparison with logical AND operators.
Select the last 3 items in an event log array
$.events[-3:]
Uses negative index slice notation to grab trailing array elements without calculating length.
Frequently Asked Questions
FAQ
What is JSONPath and what is it used for?
JSONPath is a query expression language for JSON, analogous to XPath for XML. It allows developers to extract, filter, and transform specific values from deeply nested JSON documents using concise path strings.
What does '$..' mean in JSONPath?
The double dot operator ('$..') represents recursive descent. It searches for matching property names across all nesting levels of the entire JSON hierarchy.
How do I filter JSON elements by a condition?
Use the filter expression syntax '[?(<expression>)]'. For example, '$.store.book[?(@.price < 10)]' extracts only books with a price strictly under 10.
Can I query JSONPath directly in the browser?
Yes! FormJson provides an interactive JSONPath Console (/jsonpath) with real-time matched node highlighting and zero data leakage.
Explore Related Tools & Converters
100% Client-Side JSON Formatter
Format, beautify and indent JSON payloads
Open →
JSON Validator
Line-by-line syntax diagnostics & error locator
Open →
JSON Viewer
Interactive tree explorer with path inspection
Open →
JSON Repair
Fix trailing commas, quotes and unquoted keys
Open →
JSON Diff
Semantic comparison ignoring key order
Open →
JSONPath Evaluator
Query, extract and filter JSON structures
Open →
JSON Minifier
Compress and compact JSON into single line
Open →
JSON to TypeScript
Generate typed TypeScript interfaces
Open →
JSON to Python
Generate Pydantic v2 & TypedDict models
Open →
JSON to Go
Generate idiomatic Go structs with json tags
Open →
JSON to Rust
Generate type-safe Serde structs
Open →
JSON to SQL
Generate CREATE TABLE & INSERT statements
Open →
JSON to CSV
Convert tabular JSON arrays to standard CSV
Open →
JSON to YAML
Clean converter for configuration files
Open →