{}jsonpath.online

JSONPath Cheatsheet

New to JSONPath? Start here. JSONPath is a query language for JSON (like XPath for XML). It lets you extract values from JSON using a compact path expression. Use the evaluator to test expressions instantly.

How to read a JSONPath

  • JSONPath usually starts with $ (the root JSON value).
  • Use dot notation for properties: $.store.
  • Use brackets for array indexes and special keys: $['weird-key'].
  • Many expressions return multiple matches, so tools often output an array of results.

Sample JSON

The evaluator homepage uses a sample JSON like this. You can use it to follow along:

{
  "store": {
    "book": [
      { "category": "reference", "title": "Sayings", "price": 8.95 },
      { "category": "fiction", "title": "Sword", "price": 12.99 },
      { "category": "fiction", "title": "Moby Dick", "price": 8.99 }
    ],
    "bicycle": { "color": "red", "price": 19.95 }
  }
}

Common syntax (quick table)

TokenMeaningExample
$Root object/array$.store.book (try)
@Current node (in filters)$.store.book[?(@.price < 10)] (try)
*Wildcard$.store.* (try)
..Recursive descent$..title (try)
[n]Array index$.store.book[0] (try)
[a,b]Union$.store.book[0,2] (try)
[start:end]Slice$.store.book[0:2] (try)
[?()]Filter expression$.store.book[?(@.category=='fiction')] (try)

Beginner examples

Here are the patterns most people use day-to-day:

  • Get a property: $.store.bicycle (try)
  • Get one field from each item in an array: $.store.book[*].title (try)
  • Filter by a condition: $.store.book[?(@.price < 10)] (try)
  • Pick multiple properties (varies by implementation): $['store']['bicycle','book'] (try)
  • Search for keys at any depth: $..price (try)

Common mistakes

  • Mixing up arrays vs objects (e.g. using [0] on an object key).
  • Keys with special characters: use brackets like $['my-key'] instead of dot notation.
  • Different libraries support different JSONPath features. If something doesn't work, check the implementation used in your language.

Tips

  • If results are empty, double-check whether a node is an object or an array.
  • Not all JSONPath implementations support the exact same syntax. Use the language landing pages for library-specific snippets: Integrations.