JSONPath Syntax Reference

JSONPath operators, filters and recursive descent with IETF RFC 9535 syntax

Interactive JSONPath syntax reference covering RFC 9535 segments — root, child, recursive descent, wildcards, array slices, filter expressions and function extensions — each with an example expression and what it selects.

What is RFC 9535?

RFC 9535 is the 2024 IETF standard that finally specifies JSONPath formally, ending years of divergent implementations. It defines the root identifier $, child segments, the descendant segment .., wildcards, array slices, filter selectors and a small set of function extensions like length() and count().

JSONPath is a query language for JSON, the JSON equivalent of XPath for XML. It lets you select nodes from a JSON document with a compact path expression. After years of incompatible implementations, IETF RFC 9535 (2024) standardised the syntax. This reference lists the standard segments and selectors with examples.

How it works

Every JSONPath starts at the root identifier $. You then chain segments that each narrow or expand the set of selected nodes: .name or ['name'] for a child, [*] for every element, .. to descend into all descendants, [0] or [1:3] for array indices and slices, and ?<expr> to filter. Inside a filter, @ refers to the item currently being tested. The engine evaluates the path left to right, producing a node list.

Worked example

Given this document:

{ "store": { "books": [
  { "title": "A", "price": 8 },
  { "title": "B", "price": 15 }
] } }
  • $.store.books[*].title selects ["A", "B"]
  • $..price selects [8, 15] (recursive descent)
  • $.store.books[[email protected] < 10].title selects ["A"] (filter)

Notes and tips

Recursive descent .. is convenient but scans the whole subtree, so prefer an explicit path on large documents. Filter comparisons are type-aware: comparing a string to a number is simply false rather than an error. Use length() and count() function extensions for size-based filters, e.g. $.items[?length(@.tags) > 0].