JSONPath Cheat Sheet

JSONPath is a powerful query language for JSON, similar to XPath for XML. It allows you to extract specific data from a JSON document. This cheat sheet provides a quick reference to common JSONPath expressions.

It is widely used in APIs, testing tools, and data processing pipelines.

Basic Syntax

ExpressionDescriptionExample
$The root object/element.$
. or []Child operator.$.store.book
*Wildcard. All elements.$.store.*
..Deep scan.$..author
[]Array index.$.store.book[0]
[,]Union.$.store.book[0,1]
[start:end]Slice.$.store.book[0:2]
?()Filter.$.store.book[?(@.price < 10)]

Filter Operators

OperatorDescriptionExample
==Equal[?(@.price == 10)]
!=Not equal[?(@.category != 'fiction')]
<Less than[?(@.price < 10)]
>Greater than[?(@.price > 10)]
&&AND[?(@.price < 20 && @.category == 'fiction')]
||OR[?(@.price < 10 || @.category == 'reference')]

Examples

Given a JSON object like:

{
  "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 }
    ],
    "bicycle": { "color": "red", "price": 19.95 }
  }
}
  • $.store.book[*].author → ["Nigel Rees", "Evelyn Waugh"]
  • $..price → [8.95, 12.99, 19.95]
  • $.store.book[?(@.category == 'fiction')].title → ["Sword of Honour"]
  • $..book[0] → First book object

Tips

  • Deep scan (..) can be slow on large JSON
  • Use filters to narrow results
  • Prefer direct paths when possible

Try JSONPath Now!

Use our online JSONPath Evaluator to test your expressions.

Open JSONPath Evaluator →