Blog post
JSONPath Guide: Query JSON Data Like SQL (with Examples)
Learn JSONPath syntax to query JSON data — basic expressions, wildcards, filters, recursive descent, and array slices. Includes JavaScript and Python examples.
Shashank Jain
Author


Article
What is JSONPath?
JSONPath is a query language for JSON, similar to XPath for XML. It lets you extract specific values from complex JSON structures using path expressions.
Basic Syntax
| Expression | Meaning |
|---|---|
| $.store.book[0].title | First book title |
| $.store.book[*].author | All book authors |
| $..author | All authors anywhere (recursive) |
| $.store.book[?(@.price < 10)] | Books cheaper than 10 |
| $.store.book[-1] | Last book |
| $.store.book[0:2] | First two books (slice) |
Filter Expressions
// All users with age over 18
$.users[?(@.age > 18)]
// Products in stock
$.products[?(@.inStock == true)]
// Items matching a string
$.items[?(@.status == 'active')]JavaScript: jsonpath-plus
import { JSONPath } from 'jsonpath-plus';
const result = JSONPath({
path: '$.store.book[?(@.price < 10)].title',
json: data
});
console.log(result); // array of matching valuesPython: jsonpath-ng
from jsonpath_ng import parse
expr = parse('$.store.book[*].author')
matches = [m.value for m in expr.find(data)]
print(matches)Test JSONPath expressions live against your own JSON using the JSONPath Tester at jsondecode.com.
Keep reading
Recent blogs

May 22, 2026
JSONPath Guide: Query JSON Data Like SQL (with Examples)
Learn JSONPath syntax to query JSON data — basic expressions, wildcards, filters, recursive descent, and array slices. Includes JavaScript and Python examples.

May 22, 2026
How to Convert JSON to TypeScript Interfaces Automatically
Learn how to convert JSON to TypeScript interfaces — manually, with tools, and with AI. Includes nested objects, arrays, optional fields, and Zod schema generation.

May 22, 2026
JSON Schema Validation: A Complete Guide with Examples
Learn JSON Schema validation from scratch — Draft 7 syntax, required fields, type constraints, pattern matching, array validation, and validation with AJV in JavaScript.