FormatList
JSONPath Learning Hub

JSONPath Examples, Syntax & Query Playground

Learn JSONPath with real examples. Test expressions instantly against live JSON data. Explore arrays, filters, recursive queries, and Kubernetes JSONPath.

Real-time playground 100% Private · No upload Interactive examples

Interactive JSONPath Playground

JSON Input
JSONPath Expression
$
Results

Enter JSON and a JSONPath expression,
then click Run Query

JSONPath Syntax Cheat Sheet

SyntaxNameDescription
$RootThe root object or array
.propertyDot notationChild operator — access a property
['property']Bracket notationAlternative property access (quoted)
[0]Array indexAccess element by zero-based index
[*]WildcardAll elements in an array
[0,1,2]UnionSelect multiple specific indices
[0:5]SliceRange of elements (start:end)
[0:5:2]Slice with stepRange with step increment
..Recursive descentDeep search at any nesting level
?()FilterFilter elements by condition
@Current nodeReferences current item in a filter
==, !=, <, >Comparison opsCompare values in filters
&&, ||Logic opsCombine conditions (AND, OR)
{.items[*]}Kubernetes styleWrap with {} for kubectl output

JSONPath Examples Library

Simple property access
JSON
{
  "user": {
    "name": "Tom",
    "age": 30,
    "active": true
  }
}
JSONPath$.user.name
Result"Tom"
Nested property access
JSON
{
  "order": {
    "customer": {
      "name": "Alice",
      "email": "alice@example.com"
    },
    "total": 49.99
  }
}
JSONPath$.order.customer.email
Result"alice@example.com"
Bracket notation
JSON
{
  "user-info": {
    "first-name": "Bob"
  }
}
JSONPath$['user-info']['first-name']
Result"Bob"

AI Explain JSONPath

Understand any JSONPath in plain English

Common JSONPath Mistakes

1

Missing root symbol $

Problem: Writing `.store.book` instead of `$.store.book`

Fix: Always start your JSONPath expression with `$` to indicate the root of the document. The only exception is the `@` symbol used inside filter expressions.

2

Incorrect array index

Problem: Using 1-based indexing like `$.users[1]` expecting the first element

Fix: JSONPath uses zero-based indexing. `$.users[0]` returns the first element, `$.users[1]` returns the second.

3

Filter syntax errors

Problem: Forgetting `@` in filters, e.g., `$.users[?(.age > 18)]`

Fix: Always use `@` to reference the current item inside a filter: `$.users[?(@.age > 18)]`.

4

Recursive query confusion

Problem: Expecting `$..name` to only match direct children

Fix: Recursive descent (`..`) searches ALL levels. `$..name` matches the `name` field at any depth in the JSON document. Use `$.name` if you only want the top-level field.

5

String comparison in filters

Problem: Using unquoted strings like `$.users[?(@.role == admin)]`

Fix: String values in filter expressions must be quoted: `$.users[?(@.role == 'admin')]`.

6

Kubernetes curly brace scope

Problem: Forgetting `{}` when using kubectl, or using them where not needed

Fix: Kubernetes requires wrapping JSONPath in `{}` for kubectl commands. For non-Kubernetes use, the curly braces are not standard JSONPath and may cause errors.

JSONPath FAQ

What is JSONPath?

JSONPath is a query language for navigating and extracting data from JSON documents. Think of it as XPath for JSON — it lets you address specific parts of a JSON structure using path expressions like $.store.book[0].title.

How do I query arrays with JSONPath?

Use bracket notation to access array elements. $[*] returns all elements, $[0] returns the first element, and $[0:3] returns a slice. Combine with dot notation to access nested properties: $.users[*].name gets all user names.

How do I use filters in JSONPath?

Filters use the ?() syntax: $[?(@.price < 20)] filters items where price is less than 20. The @ symbol represents the current item being evaluated. You can use comparison operators (==, !=, <, >, <=, >=) and logical operators (&&, ||).

How do I filter with multiple conditions?

Use && (AND) and || (OR) inside filter expressions. For example, $.users[?(@.age > 18 && @.active == true)] matches users older than 18 who are active. $.users[?(@.role == 'admin' || @.role == 'editor')] matches admins OR editors.

How do I search tags in JSONPath?

Use bracket indexing or wildcards on tag arrays. $.products[?(@.tags[0]=='tech')] matches products whose first tag is 'tech'. $.products[?(@.tags[*]=='mobile')] matches products where any tag equals 'mobile'. For multiple tags: $.products[?(@.tags[*]=='tech' && @.tags[*]=='mobile')].

How do I use JSONPath with kubectl?

Kubernetes uses a slightly different syntax: wrap the expression in curly braces, e.g., {.items[*].metadata.name}. This returns all pod names from a kubectl JSON output. Use {.items[*].status.podIP} to get all pod IPs.

What is the difference between JSONPath and JSON Pointer?

JSONPath is a query language that can return multiple values, supports filters, wildcards, and recursive descent. JSON Pointer (RFC 6901) is simpler — it only points to a single location using /-separated paths. JSONPath is better for querying; JSON Pointer is better for referencing specific nodes.

JSONPath — the complete guide to querying JSON

JSONPath is the standard query language for JSON documents — like XPath for XML. Whether you're extracting data from APIs, automating kubectl commands, or building data pipelines, JSONPath gives you precise control over which values to retrieve. FormatList's JSONPath playground lets you learn syntax, test expressions, and see results instantly.

Why learn JSONPath?

  • API testing — Extract specific fields from large API responses without writing scripts.
  • Kubernetes — Use kubectl get -o jsonpath=... to filter pod info, IPs, and names.
  • Data pipelines — Map JSON fields in ETL tools that support JSONPath expressions.
  • Configuration management — Reference values in JSON config files with precise path expressions.

What you'll find on this page

  • Interactive Playground — Paste JSON, write JSONPath, see results instantly.
  • Syntax Cheat Sheet — Quick reference for all JSONPath operators.
  • Examples Library — Ready-to-run examples organized by category: Basic, Arrays, Filters, Multiple Conditions, Tags, Recursive, and Kubernetes.
  • AI JSONPath Explainer — Type any expression to get a plain-English explanation.
  • Common Mistakes — Avoid the most frequent JSONPath pitfalls.