[ "Go in Action", "TypeScript" ]
About JSONPath Finder
When you face a deeply nested JSON and want to pull out a field or filter elements by a condition, JSONPath is the most direct query tool — a syntax cousin of XPath for JSON. This tool runs JSONPath queries locally in your browser, showing matches and the hit count in real time, with built-in example expressions you can apply in one click. It supports the root symbol ($), dot child access, bracket indices and slices, the wildcard (*), recursive descent with two dots ($..price), and predicate filters in brackets such as [?(@.price<30)] where @ points to the current element. Results always come back as a JSON array, and each matched node can be shown with its full path expression for direct use in code. Working with a new API payload, you can refine the expression step by step and narrow a complex filter gradually rather than writing one long, hard-to-debug query. Nothing is uploaded, so real production JSON is safe to paste. One misuse is conflating wildcard selection with filtering: the first returns everything and the second applies a condition, and their counts differ sharply, so not printing the matched paths first easily looks like a broken expression. Another is treating the result as a single value — the expression crosses arrays so the result is always a collection, and even a single match should be handled as one, since taking the first element silently breaks when the data changes. Between approaches, direct key access is simpler and faster but requires knowing the structure while writing the code, whereas a query language suits structures that change or operations spanning many records at once, at the cost of an extra syntax. The deciding question is stability: direct access reads better for a stable interface, while a query language survives longer against third-party or multi-version data, since a change in nesting does not force a code change. Bring query expressions under test along with the code: a change in the structure often does not make the expression error but turns three results into two, and that silent shrinkage is the hardest to notice. Fix a sample document and an expected count per key expression, run those cases when the structure or API version changes, and catch the problem before it spreads. A final premise is performance: query expressions generally traverse the document, so running many of them over large data slows processing noticeably while direct key access reads in one step after parsing. On bulk, stable data, use the expression to discover the path and then switch to direct access in code, which combines development flexibility with runtime efficiency and is this tool most practical use. Compared with regex over text, the advantage is understanding structure: regex matches character shapes and hits a same-named field at any depth, while a path expression matches by level and distinguishes them. Prefer path expressions for structured data and leave regex to unstructured text, since the wrong direction spends effort excluding false matches.
How It Works Internally
The expression locates nodes with a path syntax, and unlike direct key access it can cross arrays, so one expression may match many paths and the result is always a collection rather than a single value. Distinguish wildcard selection, which returns everything, from filtering, which applies a condition; the counts differ sharply, so print the matched paths before inspecting values.
$.items[*].id against a document with three itemsReturns a collection of three paths rather than one id — the count is itself a useful debugging signalMeasured on This Page
| Direct | $.store.bicycle.color yields ["red"] |
|---|---|
| Wildcard and recursive | $.store.books[*].title lists all three; $..price finds all four prices including 199 nested two levels down |
| Index and slice | $.store.books[0] returns the whole object; [1:3] returns the last two |
| Filter | $.store.books[?(@.price > 30)].title leaves only Go in Action |
| Edge cases | $.nope gives [] while $.empty gives [[]] — matching an empty array is distinct from matching nothing |
| Order | Results follow document order |
Two easy confusions: $.nope returns an empty array while $.empty returns [[]] — one is 'no match', the other 'matched an empty array', and they mean different things. Also, filters like ?(@.price > 30) evaluate over array elements, not object fields. This page is built on jsonpath-plus and matched Python's jsonpath-ng on all ten cases, but JSONPath still has no formal standard, so exotic extensions differ between implementations — spot-check complex expressions before moving them across tools.
How to Use
- Open "JSONPath Finder"
- Paste JSON on the left and type a JSONPath up top
- The match count and result update as you type
- Click an example expression to try a common pattern
- Copy the result pane for use in code or queries
Use Cases
- Debug API responses — Pull a specific field out of a complex response to verify the data is as expected.
- Bulk-extract data — Use expressions like $.price to grab every field of the same name at once.
- Conditional filtering — Use [?(@.price<30)] to filter matching elements and quickly locate target data.
- Learn JSONPath — Write and see results alongside the examples to master JSONPath syntax fast.
- Design data mapping — When designing field mapping for low-code or pipelines, verify paths here first.
- Verify API contract paths — Run a JSONPath expression from your API contract against a real response to confirm the field exists at the expected path.
- Extract error details — Use $.errors[*].message to collect all user-facing error strings from a validation response in one go.
FAQ
Which JSONPath syntax is supported?
Mainstream JSONPath: $ root. child, [] index, * wildcard. recursive descent, and [?(@.field)] filter expressions.
Why is the result an array?
JSONPath may match multiple nodes, so results are always returned as an array, even a single hit is wrapped in one.
What if the expression is wrong?
An invalid expression shows "Invalid JSONPath"; fix it to re-query in real time without affecting the original JSON.
Can it handle large JSON?
Yes, queries run locally. Complex recursive queries on very large data may lag slightly — trim it with our JSON Formatter first.
Is it the same as jq?
Similar idea, different syntax. JSONPath is closer to XPath style; if you know jq, treat this as a visual in-browser alternative.
What is the difference between @ and $?
$ refers to the JSON document root, while @ refers to the element currently being evaluated (mainly used in predicate filters). Mixing them up often yields empty results or parse errors.
Why doesn't $.data[*].id match anything?
Usually the path does not match the real structure. Common causes: data is null or an object rather than an array (in that case write $.data.id); the array elements have no id field; or there are two fields named data at different depths. If you are unsure about the shape, inspect $.data first to confirm the structure, then use recursive descent $..id to grab every field named id at once and, with the live hit count and path column here, narrow down to the exact expression. Validating the expression step by step down from the $ root, rather than writing one long path blind, makes it far easier to spot which level went wrong.
What do $ and @ mean in JSONPath?
$ is the root (every expression starts there) and @ is the current element inside a filter. $..book[?(@.price<10)] means: from the root, recursively find book arrays and keep elements whose price is under 10. Confusing the two is why expressions fail.