What Is JSONPath?
JSONPath is a lightweight query language used to select, filter, and extract values from JSON data. It works similarly to XPath for XML, but is designed for JSON objects and arrays.
- Beginner friendly explanation
- Real examples included
- Compare related standards
- Try queries live
What JSONPath Is
Use JSONPath when you need specific values inside nested JSON without manually traversing objects. Instead of writing loops and if checks, you write a small selector that returns exactly what you need.
Common use cases
- API responses
- Automation workflows
- Frontend state data
- Testing and assertions
Basic Syntax
JSONPath expressions usually start with $ (the root). Then you select nested properties with dot notation.
Meaning: select name inside user.
Meaning: select the first order’s total.
Wildcards
* matches all children. With arrays, [*] returns every element.
Recursive Descent
.. searches nested descendants. Use it when you don’t know where a field lives in the tree.
Filters
Filters return matching items based on conditions. A common form is [?(@.field > 10)], where @ refers to the current candidate element.
Note: filter support varies by implementation. If a query doesn’t work in one library, try it in your target environment or adjust syntax.
Slices
Slices select ranges from arrays. For example, [0:3] selects the first three items. Some engines support slices; others may not.
JSONPath vs JSON Pointer
JSON Pointer (RFC 6901) identifies an exact location. JSONPath is more flexible and can return multiple matches.
| Feature | JSONPath | JSON Pointer |
|---|---|---|
| Goal | Query and extract many values | Reference a single exact location |
| Wildcards / recursion | Common (*, ..) | Not supported |
| Best for | Testing, monitoring, automation, projection | Patches, precise lookups, deterministic paths |
Performance Tips
- Query specific branches first (start with a narrower prefix).
- Avoid broad recursive searches (
..) on huge payloads. - Validate/format JSON before querying for faster iteration.
- Test selectors with representative sample data.
Security Notes
- Avoid executing untrusted expressions inside sensitive systems.
- Validate user input if you accept ad-hoc JSONPath strings.
- Large payloads and broad queries can cause high CPU usage.
- Tools on this site run in the browser—no JSON is uploaded.
FAQ
Is JSONPath a standard?
JSONPath is widely adopted, but support varies by implementation. Always test expressions in your target tool.
What does $ mean?
$ refers to the root JSON document.
What does .. mean?
.. is recursive descent: it searches for matches anywhere under the current node.
Are filters always supported?
No. Filter support varies by JSONPath engine and may use different grammar.
What is the difference from JSON Pointer?
JSON Pointer references an exact location; JSONPath can return multiple matches using wildcards, recursion, and filters.
Can I use JSONPath with APIs?
Yes. It’s commonly used to extract fields from sample API responses for tests, monitoring, and docs.
Is this page free?
Yes. The article and linked tools are free to use.
Where can I test expressions live?
Use JSONPath Tester or JSONPath Online.
Try It Live
Try JSONPath tools on your own data. Paste JSON, run an expression, then copy the result into tests, scripts, or docs.
Related tools