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
JSON
Sample JSON document
{ "user": { "id": 1, "name": "Alice", "profile": { "city": "Pune", "tags": ["dev", "admin"] } }, "orders": [ { "id": "o_1", "total": 19.99, "status": "paid" }, { "id": "o_2", "total": 5.0, "status": "pending" } ] }
Try queries live
Paste JSON and evaluate selectors in the JSONPath Tester.
Run in browser
Prefer a fast playground? Use JSONPath Online.

Basic Syntax

JSONPath expressions usually start with $ (the root). Then you select nested properties with dot notation.

JSONPath
Root selector

Meaning: select name inside user.

JSONPath
Array index

Meaning: select the first order’s total.

Wildcards

* matches all children. With arrays, [*] returns every element.

JSONPath
All order totals
Clean your sample JSON
If your payload is hard to read, run it through JSON Formatter first.

Recursive Descent

.. searches nested descendants. Use it when you don’t know where a field lives in the tree.

JSONPath
Find all totals anywhere

Filters

Filters return matching items based on conditions. A common form is [?(@.field > 10)], where @ refers to the current candidate element.

JSONPath
Example filter

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
First three orders

JSONPath vs JSON Pointer

JSON Pointer (RFC 6901) identifies an exact location. JSONPath is more flexible and can return multiple matches.

FeatureJSONPathJSON Pointer
GoalQuery and extract many valuesReference a single exact location
Wildcards / recursionCommon (*, ..)Not supported
Best forTesting, monitoring, automation, projectionPatches, 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.

JSONPath Tester
Try selectors against JSON with helpful output. Open tester
JSONPath Online
Fast in-browser evaluator for quick checks. Open evaluator
JSON Formatter
Beautify payloads before writing selectors. Format JSON
JSON to YAML
Convert JSON to YAML for configs and docs. Convert

Related tools