Skip to content
πŸ› οΈToolsShed

JSONPath Tester

Test JSONPath expressions against JSON data.

About this tool

JSONPath is a query language for JSON data, similar to XPath for XML. The JSONPath Tester helps developers and data analysts validate and debug JSONPath expressions by testing them directly against sample JSON documents. This tool eliminates guesswork when working with APIs, configuration files, or complex data structures that require precise path navigation.

To use the tool, paste your JSON data into the input field and enter a JSONPath expression in the expression field. As you type, the tester immediately shows which elements match your expression, along with their values. Common patterns include $. for root access, .property for object properties, [0] for array indices, and [*] to select all array elements. The results display all matching paths and values, making it easy to refine your query until it extracts exactly what you need.

Frequently Asked Questions

Code Implementation

# pip install jsonpath-ng
from jsonpath_ng import parse

data = {
    "store": {
        "book": [
            {"title": "Moby Dick", "author": "Herman Melville", "price": 8.99},
            {"title": "The Great Gatsby", "author": "F. Scott Fitzgerald", "price": 12.99},
            {"title": "1984", "author": "George Orwell", "price": 6.99}
        ]
    }
}

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

# Filter books cheaper than $10
expr2 = parse("$.store.book[?(@.price < 10)]")
cheap_books = [match.value for match in expr2.find(data)]
print(cheap_books)
# [{'title': 'Moby Dick', ...}, {'title': '1984', ...}]

# Recursive descent: find all authors anywhere in the document
expr3 = parse("$..author")
authors = [match.value for match in expr3.find(data)]
print(authors)
# ['Herman Melville', 'F. Scott Fitzgerald', 'George Orwell']

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.