Home → JSONPath Cheatsheet

JSONPath Cheatsheet: Complete Syntax Reference with Examples (2026)

📅 Updated March 2026 ⏱ 10 min read 🔍 For backend & data developers

JSONPath is the standard way to query and extract data from JSON documents. Think of it as SQL for JSON, or XPath for JSON. This cheatsheet covers every operator, expression, and pattern you'll encounter — with real examples for each.

Test JSONPath expressions live

Enter your JSON and run any expression from this cheatsheet instantly.

Open JSONPath Evaluator →

Quick Reference: All JSONPath Operators

Root & Navigation

SymbolMeaning
$Root element
.Child element
..Recursive descent
*Wildcard (all)
@Current element

Array Operators

ExpressionMeaning
[0]First element
[-1]Last element
[0,2]Elements 0 and 2
[0:3]Slice: elements 0–2
[::2]Every 2nd element

Filter Expressions

ExpressionMeaning
[?(@.age)]Has age property
[?(@.age > 18)]age greater than 18
[?(@.name == "x")]name equals "x"
[?(@.tags =~ /js/)]Regex match
[?(!@.disabled)]Negation filter

Comparison Operators

OperatorMeaning
==Equal to
!=Not equal
<Less than
>Greater than
<=Less or equal
>=Greater or equal
&&Logical AND
||Logical OR

Sample JSON for All Examples

All examples below use this JSON document:

{
  "store": {
    "name": "The Book Shop",
    "books": [
      { "title": "Clean Code", "author": "Robert Martin", "price": 29.99, "category": "programming", "tags": ["code", "best-practices"] },
      { "title": "The Pragmatic Programmer", "author": "David Thomas", "price": 35.00, "category": "programming" },
      { "title": "Design Patterns", "author": "GoF", "price": 49.99, "category": "architecture" },
      { "title": "JavaScript: The Good Parts", "author": "Douglas Crockford", "price": 19.99, "category": "javascript" }
    ],
    "manager": { "name": "Jane Doe", "email": "jane@bookshop.com" }
  },
  "currency": "USD"
}

Basic Path Navigation

Access a direct child

$.currency
// Result: "USD"

$.store.name
// Result: "The Book Shop"

$.store.manager.email
// Result: "jane@bookshop.com"

Access array elements by index

$.store.books[0]
// Result: { "title": "Clean Code", "author": "Robert Martin", ... }

$.store.books[0].title
// Result: "Clean Code"

$.store.books[-1].title
// Result: "JavaScript: The Good Parts"  (last element)

Wildcards

The * wildcard matches all children of an element:

$.store.books[*].title
// Result: ["Clean Code", "The Pragmatic Programmer", "Design Patterns", "JavaScript: The Good Parts"]

$.store.books[*].price
// Result: [29.99, 35.00, 49.99, 19.99]

$.store.*
// Result: all values inside store (books array, manager object)

Recursive Descent (..)

The .. operator searches recursively at any depth:

$..title
// Result: all title properties anywhere in the document
// ["Clean Code", "The Pragmatic Programmer", "Design Patterns", "JavaScript: The Good Parts"]

$..name
// Result: ["The Book Shop", "Jane Doe"]  — finds name at any level

$..price
// Result: [29.99, 35.00, 49.99, 19.99]

Use recursive descent sparingly. On large documents, .. is slower than a direct path since it must scan the entire tree.

Array Slicing

Array slices work like Python slices — [start:end:step]:

$.store.books[0:2]
// Result: first 2 books (index 0 and 1)

$.store.books[1:]
// Result: all books from index 1 onwards

$.store.books[:2]
// Result: first 2 books (same as [0:2])

$.store.books[::2]
// Result: every 2nd book (index 0, 2)

$.store.books[-2:]
// Result: last 2 books

Multiple Indexes (Union)

$.store.books[0,3].title
// Result: ["Clean Code", "JavaScript: The Good Parts"]

$.store.books[0]['title','author']
// Result: { "title": "Clean Code", "author": "Robert Martin" }

Filter Expressions

Filter expressions use ?(@.field operator value) syntax. @ refers to the current array item:

Filter by existence

$.store.books[?(@.tags)]
// Result: books that HAVE a tags property
// [{ "title": "Clean Code", ..., "tags": ["code", "best-practices"] }]

Filter by comparison

$.store.books[?(@.price < 30)].title
// Result: ["Clean Code", "JavaScript: The Good Parts"]

$.store.books[?(@.price >= 35)].title
// Result: ["The Pragmatic Programmer", "Design Patterns"]

$.store.books[?(@.price == 19.99)].title
// Result: ["JavaScript: The Good Parts"]

Filter by string equality

$.store.books[?(@.category == "programming")].title
// Result: ["Clean Code", "The Pragmatic Programmer"]

$.store.books[?(@.author != "GoF")].title
// Result: ["Clean Code", "The Pragmatic Programmer", "JavaScript: The Good Parts"]

Multiple conditions (AND / OR)

$.store.books[?(@.price < 40 && @.category == "programming")].title
// Result: ["Clean Code", "The Pragmatic Programmer"]

$.store.books[?(@.price > 45 || @.category == "javascript")].title
// Result: ["Design Patterns", "JavaScript: The Good Parts"]

Bracket Notation vs Dot Notation

JSONPath supports both dot and bracket notation. They are equivalent:

Dot NotationBracket NotationNotes
$.store.name$['store']['name']Standard access
$.store.books[0]$['store']['books'][0]Array index
N/A$['my-key']Keys with hyphens need brackets
N/A$['key with spaces']Keys with spaces need brackets

Complete Reference Table

ExpressionDescriptionExample Result
$Root objectEntire document
$.storeDirect childThe store object
$.store.*All children of storebooks array, manager, name
$..titleAll titles anywhereArray of all title values
$.store.books[0]First bookClean Code object
$.store.books[-1]Last bookJS Good Parts object
$.store.books[*].priceAll prices[29.99, 35, 49.99, 19.99]
$.store.books[0:2]First 2 booksArray of 2 books
$.store.books[?(@.price<30)]Books under $30Clean Code, JS Good Parts
$.store.books[?(@.tags)]Books with tagsClean Code only
$.store.books[0,2]Book at index 0 and 2Two specific books

JSONPath in Different Languages

JSONPath is implemented in many languages. Here's how to use it:

JavaScript / Node.js

// Using jsonpath-plus (npm install jsonpath-plus)
import { JSONPath } from 'jsonpath-plus';

const titles = JSONPath({ path: '$.store.books[*].title', json: data });
// Result: ["Clean Code", "The Pragmatic Programmer", ...]

Python

# Using jsonpath-ng (pip install jsonpath-ng)
from jsonpath_ng import parse

expr = parse('$.store.books[*].title')
matches = [match.value for match in expr.find(data)]
# Result: ["Clean Code", "The Pragmatic Programmer", ...]

Java (Spring / Jayway)

// Using Jayway JSONPath (Maven: com.jayway.jsonpath:json-path)
import com.jayway.jsonpath.JsonPath;

List<String> titles = JsonPath.read(json, "$.store.books[*].title");
// Result: ["Clean Code", "The Pragmatic Programmer", ...]

Go

// Using github.com/PaesslerAG/jsonpath
import "github.com/PaesslerAG/jsonpath"

result, _ := jsonpath.Get("$.store.books[*].title", data)

Common JSONPath Patterns

These are the patterns developers use most often:

TaskJSONPath
Get all IDs$..id
Get first item in every array$..[0]
Find active users$.users[?(@.active == true)]
Users over 18$.users[?(@.age >= 18)]
Items with price in range$.items[?(@.price >= 10 && @.price <= 50)]
All leaf node values$..*
Count items (length)$.items.length
Non-null field$.users[?(@.email != null)]

JSONPath vs XPath Comparison

FeatureJSONPathXPath
Root$/
Child./
Recursive..//
Wildcard**
Current node@.
Filter[?(@.x > 1)][@x>1]
Array index[0][1] (1-based)
Parent axisNot supported..

Key difference: JSONPath array indexes are 0-based (like JavaScript), while XPath is 1-based.

Test any JSONPath expression live

Paste your JSON and run expressions from this cheatsheet instantly — no install needed.

Open JSONPath Evaluator →

Frequently Asked Questions

What is JSONPath? +
JSONPath is a query language for JSON, similar to XPath for XML. It lets you select and extract specific elements from a JSON document using path expressions. For example, $.store.books[0].title selects the title of the first book in the store.
What does $ mean in JSONPath? +
$ represents the root element of the JSON document. Every JSONPath expression must start with $. Think of it as the entry point to the entire document — equivalent to / in XPath.
How do I filter an array with JSONPath? +
Use a filter expression: $.books[?(@.price < 20)] returns all books with price less than 20. The @ symbol refers to the current array element being evaluated. You can combine conditions with && (AND) and || (OR).
What is the difference between . and .. in JSONPath? +
A single dot (.) is a child accessor — $.user.name gets the direct name child of user. A double dot (..) is the recursive descent operator — $..name finds all name properties at any depth in the entire document.
Is JSONPath standardized? +
JSONPath was originally defined by Stefan Goessner in 2007 and has been widely adopted but not formally standardized until recently. RFC 9535 (published in 2024) is now the official IETF standard for JSONPath. Different implementations may have minor syntax variations, especially for filters and regex.
How do I get the last element in a JSONPath array? +
Use a negative index: $.books[-1] returns the last element. $.books[-2:] returns the last two elements. This works the same as Python slice notation.

Related Tools & Guides

JSONPath Online Evaluator  |  JSON Schema Tutorial  |  How to Validate JSON  |  JSON vs XML  |  JSON Formatter  |  Full JSON Cheatsheet