When JSONPath searches are useful
- Extract a list of IDs, names, prices, and similar fields from a REST API response.
- Check JSONPath expressions used for monitoring, tests, and ETL before incorporating them into code
- Extract only objects in an array that match the condition.
- Convert to JSON Pointer and share the target location in logs or reviews
Steps for checking a JSONPath expression
- Paste JSON or open a .json file. Mask sensitive information before sharing.
- Start the search with $ and specify the target hierarchy using dot notation or brackets.
- Narrow an array to the required elements using indexes, wildcards, slices, and filters.
- Check values, types, normalized paths, and JSON Pointers in search results, then copy or save them.
Notes on filter and implementation differences
JSONPath has multiple implementations, and non-standard operators and script expressions behave differently by library. Also check the specifications of the environment actually in use, and first consider whether standard comparisons, existence checks, and functions can express the requirement.
The tester does not evaluate arbitrary JavaScript code. Input JSON and query expressions are processed only in the browser, but before sharing results, check that values do not retain tokens or personal information.
Example: Extract book titles priced under 10
From JSON where the store.book array contains books with title and price, find only books priced below 10. First inspect the entire array with $.store.book[*], then add a filter.
Running $.store.book[?(@.price < 10)].title returns only the titles of elements that match the condition. Checking normalized result paths also lets you trace their locations in the original JSON.
- Enter JSON, then check all titles with $.store.book[*].title.
- Change the expression to $.store.book[?(@.price < 10)].title.
- Check extracted values, types, normalized paths, and JSON Pointers.
- Whether to copy only required values or save all results as JSON.
If the JSONPath library used by the implementation uses nonstandard syntax, also test the same expression in the actual runtime environment.
Frequently asked questions
- Can JavaScript be executed in a JSONPath expression?
- No. For safety, arbitrary JavaScript evaluation is not supported; comparisons, logical operations, existence checks, and standard functions are processed by a dedicated parser.
- What is the difference from JSON Pointer?
- JSONPath can search for multiple values using conditions and wildcards. JSON Pointer is a slash-delimited format for identifying one location and is useful when sharing the location of search results.
Try It in Your Browser
Your input is processed entirely in your browser. Keep the original data, review the output, and only then save or share it.
Open JSONPath Tester