How to query JSON with JSONPath
- Paste your JSON into Input, drop a
.jsonfile on the page, or press Open file. - Type a query in the JSONPath query box. It starts with
$, which means the whole document. - The matches appear as you type, as a JSON array. Select Copy to take them with you.
If the query has a mistake, the message says where in the query it went wrong. If the JSON itself is broken, you get the line and column.
JSONPath cheat sheet
$.store.namegets a child by name.$['first name']gets a child whose name has spaces or symbols.$.items[0]and$.items[-1]get the first and last item.$.items[1:3]is a slice,$.items[::2]takes every second item.$.items[*].nameuses a wildcard to take every item.$..pricesearches at any depth for a key calledprice.$.items[?(@.price > 10)]keeps items that pass a test. Inside a filter,@is the item being checked.$.items[?(@.tags.length > 1 && @.stock)]combines tests with&&,||and!.
Where this helps
JSONPath is a fast way to pull one value out of a big response while debugging an API, to write a test assertion, or to configure tools that accept JSONPath expressions. Try the query here first, then copy it into your code.
Tips
- Not sure of the structure? Open the document in the JSON tree viewer and click a row to copy its path.
- Turn on Show paths to see exactly which node each match came from.
- Results are limited to 10,000 matches to keep the page quick.
- The result can be turned into a table with JSON to CSV.
Privacy
Your documents and queries stay in your browser. Nothing is uploaded, stored or logged.