Developer's Guide to JSONPath Evaluator: Best Practices and Examples
August 18, 2026 · The Devs Tools Team
JSONPath is a query notation for addressing specific values inside a JSON document, similar in spirit to how XPath addresses nodes in XML. Rather than writing imperative code to walk an object graph — checking if a key exists, indexing into an array, repeating that for every level of nesting — a JSONPath expression describes the location declaratively, and an evaluator walks the document to resolve it. The notation starts from $, representing the root of the document, and descends through it using dot notation for named object keys ($.store.bicycle.color) or bracket notation for keys and indices ($.store.book[0].title, $['store']['bicycle']). Bracket notation also supports a wildcard, [*], which resolves to every element of an array or every value of an object at that position, letting a single expression extract a value across many array entries at once instead of writing a loop. This kind of query language earns its keep anywhere you need to pull a specific field out of a JSON payload without writing custom traversal code for every different shape of document — inspecting API responses, extracting a value from a config file, or writing test assertions against a subset of a larger payload.
[!TIP] Need to extract data from a JSON payload right now? Try our free, local JSONPath Evaluator to run JSONPath queries completely offline.
Core Syntax
Given this sample document:
{
"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 }
],
"bicycle": { "color": "red", "price": 19.95 }
}
}
A few representative queries:
$.store.bicycle.color → "red"
$.store.book[0].title → "Sayings of the Century"
$.store.book[1].author → "Evelyn Waugh"
$.store.book[*].title → ["Sayings of the Century", "Sword of Honour"]
$.store.bicycle[*] → ["red", 19.95]
Dot notation and bracket notation can be mixed freely — $.store.book[0].title and $['store']['book'][0]['title'] address the same value, and quoted bracket keys are useful when a key name contains characters that don't work in dot notation, like spaces or hyphens.
Wildcards Extract Across a Whole Collection
The wildcard is what turns JSONPath from "point to one value" into "point to a shape." $.store.book[*].title doesn't just index into one book — it resolves to the title field across every element of the book array in one expression, which is the pattern you reach for whenever you want "all values of field X across a list" rather than a single lookup.
Testing Queries Before Wiring Them Into Code
Because JSONPath is just a string until it's evaluated, a typo or a wrong assumption about the document's shape fails silently in many implementations rather than throwing a clear error — a mistyped key often just resolves to nothing instead of raising an exception. That makes interactively testing an expression against real sample data valuable before hardcoding it into an application: paste the actual payload shape you'll be querying in production, write the path, and confirm it resolves to what you expect rather than assuming the syntax is correct.
A Practical Workflow
- Paste a real (or representative) JSON payload rather than a synthetic minimal example, since path correctness depends on the actual nesting depth and key names.
- Start with a narrow path to a single field, confirm it resolves correctly, then broaden to a wildcard once you're confident about the structure.
- Keep in mind that different JSONPath libraries and tools support different extensions of the base syntax (filters, recursive descent, slicing) — if you're pasting an expression from documentation elsewhere, verify it against your actual evaluator rather than assuming universal support.
Conclusion
JSONPath turns "find this value inside a nested structure" into a short, declarative expression instead of hand-written traversal code, and wildcards extend that from single lookups to whole-collection extraction. Testing an expression interactively against real data before hardcoding it is the fastest way to catch a wrong assumption about the document's shape.
