ToolDeck

JSONPath Tester

Test JSONPath expressions against JSON data and see matching results

Try an example

JSON Input

Results

Runs locally · Safe to paste secrets
Results will appear here…

What Is JSONPath?

JSONPath is a query language for extracting values from JSON documents. Originally proposed by Stefan Goessner in 2007 as an analog to XPath for XML, JSONPath lets you write expressions like $.store.book[*].author to select all author fields inside a book array without writing loops or manual traversal code. The language was standardized in February 2024 as RFC 9535, published by the IETF.

A JSONPath expression always starts with $ representing the root of the document. From there you chain selectors: dot notation for object keys, bracket notation for array indices, wildcards for all children, and the recursive descent operator (..) to search through every level of nesting. Filter expressions like [?(@.price < 10)] let you select elements based on conditions evaluated against their values.

JSONPath is used in API testing tools like Postman, observability platforms like Datadog and Splunk, workflow engines like Apache NiFi, and programming libraries across JavaScript, Python, Go, Java, and C#. Testing your expressions against real data before embedding them in code or config files prevents silent failures when the JSON structure does not match your assumptions.

Why Use This JSONPath Tester?

Writing JSONPath expressions by hand is error-prone. A missing dot, wrong bracket type, or incorrect filter syntax can return empty results with no error message. This tool gives you immediate visual feedback on what your expression matches.

Instant Results
Paste JSON, type an expression, and see matching values update in real time. No need to run a script or reload a page to check your query.
🔒
Privacy-First
All evaluation runs in your browser. Your JSON data never leaves your machine, so you can safely test expressions against production API responses or config files containing credentials.
📋
Copy Results Directly
Copy matched output as JSON with one click. Paste it into test assertions, documentation, or API response examples without reformatting.
🛠️
No Setup Required
No npm packages to install, no Python virtualenvs to create. Open the page, paste your data, and start querying. Works on any device with a browser.

JSONPath Use Cases

Frontend Development
Extract the exact nested values you need from API responses before wiring them into React state or Vue computed properties. Test your path expressions against the real API payload first.
Backend API Testing
Postman and REST-assured use JSONPath to assert response bodies. Build and verify your assertion expressions here before copying them into test scripts, reducing debug cycles.
DevOps Configuration
Kubernetes custom resource definitions, AWS Step Functions, and Terraform data sources accept JSONPath expressions to extract values from JSON outputs. Validate your path before deploying.
QA Test Automation
Write JSONPath-based assertions for contract tests and integration tests. Verify that your expressions correctly match expected values when the JSON structure has optional or nullable fields.
Data Pipeline Extraction
Apache NiFi, Logstash, and custom ETL scripts use JSONPath to extract fields from semi-structured log data and event streams. Test expressions against sample payloads before pipeline deployment.
Learning and Experimentation
Students and developers new to JSONPath can try different expressions against sample JSON to understand how wildcards, recursive descent, and filters work without a local environment.

JSONPath Syntax Reference

RFC 9535 defines the standard JSONPath syntax. The table below covers the operators you will use in most queries. All expressions start with $ (the root node) and chain one or more selectors to navigate the document structure.

OperatorDescriptionExample
$Root element$.store
.keyChild property$.store.book
[n]Array index (zero-based)$.store.book[0]
[*]All elements in array/object$.store.book[*]
..Recursive descent$..author
[start:end]Array slice$.store.book[0:2]
[?()]Filter expression$.store.book[?(@.price<10)]
@Current node (inside filter)$.store.book[?(@.isbn)]

JSONPath vs jq vs XPath

JSONPath, jq, and XPath solve the same problem (querying structured data) for different formats and use cases. JSONPath targets JSON and is available as a library in most languages. jq is a standalone CLI tool with its own Turing-complete filter language. XPath operates on XML and is part of the W3C specification stack.

FeatureJSONPathjqXPath
Data formatJSONJSONXML
Access first element$.store.book[0].store.book[0]/store/book[1]
Recursive search$..price.. | .price?//price
Filter expression[?(@.price<10)]select(.price < 10)[price<10]
SpecificationRFC 9535stedolan.github.ioW3C XPath 3.1

Code Examples

How to evaluate JSONPath expressions in popular languages and tools. Each example uses the same bookstore JSON structure for comparison.

JavaScript (jsonpath-plus)
import { JSONPath } from 'jsonpath-plus';

const data = {
  store: {
    book: [
      { title: 'Moby Dick', price: 8.99 },
      { title: 'The Great Gatsby', price: 12.99 }
    ]
  }
};

// Get all book titles
JSONPath({ path: '$.store.book[*].title', json: data });
// → ['Moby Dick', 'The Great Gatsby']

// Recursive descent — find every price in the document
JSONPath({ path: '$..price', json: data });
// → [8.99, 12.99]

// Filter — books under $10
JSONPath({ path: '$.store.book[?(@.price < 10)]', json: data });
// → [{ title: 'Moby Dick', price: 8.99 }]
Python (jsonpath-ng)
from jsonpath_ng.ext import parse
import json

data = {
    "store": {
        "book": [
            {"title": "Moby Dick", "price": 8.99},
            {"title": "The Great Gatsby", "price": 12.99}
        ]
    }
}

# Get all book titles
expr = parse("$.store.book[*].title")
titles = [match.value for match in expr.find(data)]
# → ['Moby Dick', 'The Great Gatsby']

# Recursive descent — all prices
expr = parse("$..price")
prices = [match.value for match in expr.find(data)]
# → [8.99, 12.99]

# Filter — books under $10
expr = parse("$.store.book[?price < 10]")
cheap = [match.value for match in expr.find(data)]
# → [{"title": "Moby Dick", "price": 8.99}]
Go (ohler55/ojg)
package main

import (
    "fmt"
    "github.com/ohler55/ojg/jp"
    "github.com/ohler55/ojg/oj"
)

func main() {
    src := `{
        "store": {
            "book": [
                {"title": "Moby Dick", "price": 8.99},
                {"title": "The Great Gatsby", "price": 12.99}
            ]
        }
    }`

    obj, _ := oj.ParseString(src)

    // Get all book titles
    expr, _ := jp.ParseString("$.store.book[*].title")
    results := expr.Get(obj)
    fmt.Println(results)
    // → [Moby Dick The Great Gatsby]

    // Recursive descent — all prices
    expr2, _ := jp.ParseString("$..price")
    fmt.Println(expr2.Get(obj))
    // → [8.99 12.99]
}
CLI (jq alternative syntax)
# jq uses its own syntax, not JSONPath, but solves the same problem.
# Mapping common JSONPath patterns to jq:

# $.store.book[*].title → get all titles
echo '{"store":{"book":[{"title":"Moby Dick"},{"title":"Gatsby"}]}}' | \
  jq '.store.book[].title'
# → "Moby Dick"
# → "Gatsby"

# $..price → recursive descent for "price" keys
echo '{"a":{"price":1},"b":{"price":2}}' | \
  jq '.. | .price? // empty'
# → 1
# → 2

# Filter: books where price < 10
echo '{"store":{"book":[{"title":"A","price":8},{"title":"B","price":12}]}}' | \
  jq '.store.book[] | select(.price < 10)'
# → {"title":"A","price":8}

Frequently Asked Questions

What is the difference between JSONPath and jq?
JSONPath is a query language designed to be embedded in applications as a library. It returns matching values from a JSON document using path expressions. jq is a standalone command-line tool with a full programming language for transforming JSON, including conditionals, functions, and string interpolation. Use JSONPath when you need a query embedded in code or a tool like Postman. Use jq for ad-hoc command-line data transformation.
Is JSONPath an official standard?
Yes. The IETF published RFC 9535 ("JSONPath: Query Expressions for JSON") in February 2024. Before that, JSONPath existed only as an informal specification by Stefan Goessner from 2007, which led to inconsistencies between implementations. RFC 9535 defines the syntax, semantics, and a normalization format for interoperability.
How does recursive descent (..) work in JSONPath?
The recursive descent operator (..) searches every level of the JSON document for the key that follows it. For example, $..price returns all values associated with the key "price" regardless of how deeply they are nested. It is equivalent to a depth-first traversal that collects matching nodes. Be aware that on large documents, recursive descent can return many results and may be slower than a direct path.
Can JSONPath modify JSON data?
No. JSONPath is a read-only query language. It selects and returns values but cannot insert, update, or delete nodes. To modify JSON based on a JSONPath expression, you need to use your programming language's JSON manipulation functions after querying. Some libraries like jsonpath-ng in Python provide a set() method on match objects, but this is a library extension, not part of the JSONPath specification.
What does the @ symbol mean in JSONPath filter expressions?
The @ symbol refers to the current node being evaluated in a filter expression. In $.store.book[?(@.price < 10)], the filter iterates over each element of the book array, and @ represents each book object in turn. @.price accesses the price field of the current book. Without @, the filter would not know which node's properties to check.
How do I handle keys with special characters or spaces in JSONPath?
Use bracket notation with quotes: $['store']['book title']. Bracket notation works for any key, including those with dots, spaces, or Unicode characters. Dot notation ($.store.key) only works for keys that are valid identifiers (letters, digits, underscores). RFC 9535 requires implementations to support both single-quoted and double-quoted bracket notation.
Why does my JSONPath expression return empty results?
The most common causes are: a typo in a key name (JSONPath is case-sensitive), using dot notation for a key that contains special characters, missing the $ root symbol at the start, or assuming a value is an array when it is a single object. Paste your JSON into a tester tool and try simpler sub-expressions first (like $.store) to verify each segment of your path resolves correctly before adding more selectors.