Skip to content
Back to Blog
By JSONConvert Team··6 min read

JSONPath Query Syntax: Reference Guide

JSONPath is a query language for JSON, similar to XPath for XML. It lets you extract specific values from complex JSON structures without writing loops. Here's everything you need to know.

Basic Syntax

All JSONPath expressions start with $, which represents the root object:

Given this JSON:

Operators

ExpressionDescriptionExample
$Root object$ → entire document
.Child operator$.store → store object
..Recursive descent$..price → all prices
[]Array index or name$.store.book[0] → first book
[]Wildcard (all elements)$.store.book[] → all books
[start:end]Array slice$.store.book[0:2] → first two books
[?()]Filter expression$.store.book[?(@.price<10)]

Examples

Dot Notation vs Bracket Notation

Bracket notation is required for keys with special characters: $['key with spaces'].

Wildcards

Array Slicing

Recursive Descent

The .. operator searches all levels of the JSON tree:

This is powerful but can be slow on very large documents since it traverses every node.

Filter Expressions

Filters use @ to reference the current element:

Real-World Use Cases

Extracting API data

Kubernetes manifests

Testing and validation

JSONPath is commonly used in API testing tools (Postman, REST Assured) to assert on specific response values without parsing the entire body.

Try It

Our JSONPath evaluator lets you test expressions against your JSON data in real time. Paste your JSON, type a JSONPath expression, and see results instantly. Everything runs in your browser.

Tips

  1. Start with $ and build incrementally. Test each level before adding the next.
  2. Use .. sparingly. It's convenient but can return unexpected results from deeply nested matches.
  3. Quote string comparisons in filters: @.name == 'value', not @.name == value.
  4. Array indices are zero-based. [0] is the first element.

Related Tools