JSONPath Tester

Test and evaluate JSONPath expressions online. Filter, slice, and extract data from JSON documents instantly.

Cheat Sheet

  • $ Root object
  • @ Current object
  • . Child operator
  • .. Recursive descent
  • * Wildcard
  • [n] Array index
  • [start:end] Array slice
  • [?(@.age > 10)] Filter

Tester

Matches: 0

Place banner or text content here

Understanding JSONPath

JSONPath is a query language for JSON, similar to XPath for XML. It allows you to select and extract data from a JSON document. Our JSONPath Tester provides an interactive environment to write queries and see results in real-time, all processed locally in your browser for maximum privacy.

Step-by-Step Guide

  1. Paste your JSON: Enter your JSON data into the "INPUT JSON" editor on the left. You can also click "Load Sample" to see an example.
  2. Write a Query: Type your JSONPath expression in the input box (e.g., $.store.book[*].author).
  3. Evaluate: Click the "Evaluate" button.
  4. View Results: The matching nodes or values will appear in the "EVALUATION RESULT" editor on the right.

Common Operators

  • $: The root object/element.
  • . or []: Child operator to access properties.
  • ..: Recursive descent (deep scan).
  • *: Wildcard, matches all objects/elements.
  • [start:end:step]: Array slicing.

Implement JSONPath in your applications using popular libraries for different languages.

JavaScript / Node.js

Using the jsonpath library:

const jp = require('jsonpath');
                    
                        const data = {
                        store: {
                            book: [
                            { category: "reference", author: "Nigel Rees", title: "Sayings of the Century", price: 8.95 },
                            { category: "fiction", author: "Evelyn Waugh", title: "Sword of Honour", price: 12.99 }
                            ]
                        }
                        };
                    
                        // Extract all authors
                        const authors = jp.query(data, '$.store.book[*].author');
                        console.log(authors); // ["Nigel Rees", "Evelyn Waugh"]
Python

Using jsonpath-ng:

from jsonpath_ng import jsonpath, parse
                    
                        json_data = {
                            'foo': [{'baz': 1}, {'baz': 2}]
                        }
                    
                        jsonpath_expression = parse('foo[*].baz')
                        match = [match.value for match in jsonpath_expression.find(json_data)]
                    
                        print(match) # [1, 2]
Java

Using Jayway JsonPath:

import com.jayway.jsonpath.JsonPath;
                    
                        String json = "..."; // your json string
                        List authors = JsonPath.read(json, "$.store.book[*].author");
                    
                        System.out.println(authors);