JSONPath Query - Select Nodes from JSON in the Browser
Default path $.items[*].id against the sample catalog returns [1, 2]. Script expressions are disabled. This is not jq.
Document and path
Edit the source on the JSON editor. Compare two payloads on JSON compare.
Matches
[ 1, 2 ]
What Is a JSONPath Query Tool?
A JSONPath query tool answers a narrower question than a formatter or an editor: which nodes in this document match a path? JSONPath is closer to XPath than to a programming language. You start at the root $, walk into objects with dotted keys, and fan out over arrays with [*]. The default catalog on this page is two people. Path $.items[*].id reads every id under items. Because matches wrap as an array, the result is [1, 2] - not a rewritten document, not a jq program, and not a pretty-print of the original tree. Path $.items[0].name returns ["Ada"]. That pair of checks is the whole point of shipping a query page instead of stretching the JSON formatter.
Developers reach for JSONPath when an API dump is too large to scan by eye and too small to justify a local toolchain. You want every SKU, every nested error.message, or every href under a CMS blob. jq can do that and also map, reduce, and define functions. JSONPath cannot. GraphQL asks a server for a shaped response; JSONPath runs after you already have a JSON value in memory. SQL joins tables; JSONPath never joins two documents. Historical JSONPath engines evaluated filter scripts with JavaScript eval, which is unsafe in a web page. This implementation sets preventEval. Recursive descent such as $..id still works because it is a path, not a script. Filters that require executing an expression fail on purpose.
Output is always a pretty-printed JSON array of matches. It is not a patch, not a JSON Pointer encoder, and not a schema. To change the original document, use the JSON editor. To check a contract, use the JSON Schema validator. To see how two versions differ after you extracted a field, use JSON compare. Querying happens entirely in the browser after the page loads. The catalog and the path persist in localStorage for up to 30 days on this device. That is a draft, not a backup and not a server-side query engine.
How to Query JSON with JSONPath - Step by Step
Selecting nodes on this page takes under a minute. Matching runs live as you type.
- Paste a JSON document - Keep the default catalog or paste your own RFC 8259 JSON into the left panel. Invalid JSON is rejected before the path runs, with a line and column.
- Enter a JSONPath expression - Type $.items[*].id to collect every item id, or $..name for recursive descent. Script filters that require eval are disabled.
- Read the wrapped match array - Matches appear on the right as pretty-printed JSON. A single hit and many hits both wrap as an array.
- Copy the result or restore the sample - Click Copy to put the match array on the clipboard. Clear restores the catalog and the default path. Nothing is uploaded.
JSONPath Worked Example - Before and After
The default sample is the gold-standard check for this tool. Keep it loaded, confirm the path, and you should see the same array every time. If you do not, the document failed to parse or the path was edited.
Input - catalog JSON and path
{
"items": [
{ "id": 1, "name": "Ada" },
{ "id": 2, "name": "Grace" }
]
}
JSONPath: $.items[*].idOutput - wrapped match array
[ 1, 2 ]
The source document is unchanged. The right panel is not a pretty-print of the catalog; it is the list of selected values. Extra checks on the same sample: $.items[0].name returns ["Ada"]. $.items[1] returns the Grace object inside an array. $..name returns ["Ada","Grace"]. $.items[?(@.id==1)] may fail because script filters are disabled - use $.items[0] instead.
When You Need JSONPath - Real-World Use Cases
Collecting primary keys from a paginated catalog
List endpoints often return { items: [{ id, name }, …] } plus pagination metadata you do not care about in the moment. Path $.items[*].id is the same shape as this page's default. Paste the payload, copy the id array, and drop it into a test, a SQL IN clause, or a follow-up request. You are not writing a mapper and you are not installing jq for a thirty-second extraction.
Pulling nested error strings out of gateway envelopes
API gateways wrap failures as error.details[].message or a similar nest. The HTTP client shows a 400; the useful sentence is four objects deep. Recursive descent $..message collects every message node when you do not remember the exact envelope. If the path is stable, a precise dotted path is clearer and faster than walking the whole tree.
Harvesting SKUs or slugs before a spreadsheet import
Product dumps mix variants, images, and prices. You often need one column: SKU, handle, or slug. JSONPath returns that column as a JSON array you can paste into a sheet or feed to JSON to CSV after you rebuild a tiny array of objects. Query first when flattening the whole tree would create dozens of unused columns.
Checking which keys a generated infrastructure file actually contains
Cloud templates and policy documents are JSON with repetitive nested blocks. Before you grep a 4,000-line file, ask $..Action or $.Resources.*.Type (syntax depending on the document). You see the set of values without pretty-printing the entire template. If the file is not strict JSON, repair it first on JSON repair.
Building compact test fixtures from a production-shaped sample
A captured response is useful until it is 80 KB of noise. Selecting $.data.user.id and a handful of sibling paths gives you the values your test actually asserts. Paste those into a fixture file. The query tool does not rewrite the capture; you decide what to keep. Edit the slim document on the JSON editor afterward.
Teaching JSONPath without installing Node or jq
Workshops stall when half the room fights package managers. This page loads, shows Ada and Grace, and makes [*] versus [0] visible in seconds. Students can break the path, see an empty array or an error, and recover with Clear. That is a better first hour than a slide of XPath analogies.
Auditing which fields a client actually reads
Mobile and web clients often ignore half of a bloated payload. If you know the screens, you can write paths for the fields that appear in the UI and collect them from a real response. The leftover keys are candidates to drop from the API. Pair with JSON compare when you want a full tree diff between two backend versions rather than a list of selected nodes.
Extracting every URL nested under a CMS document
CMS JSON hides links in blocks, modules, and metadata. Recursive descent on a key such as $..href or $..url produces a checklist for link rot, CDN migration, or CSP review. It will also pick up unrelated keys named the same way - read the array before you treat it as a sitemap.
JSONPath vs jq, JSON Pointer, GraphQL, and Sibling Tools
Use this table when you are choosing a selector rather than a formatter. Each column is a different job.
| Need | JSONPath (this page) | jq | JSON Pointer | JSON Schema | JSON editor |
|---|---|---|---|---|---|
| Collect every id in an array | ✓ $.items[*].id | ✓ .items[].id | One node only | Validates, does not select | Edit, does not query |
| Map, reduce, custom functions | No | ✓ | No | No | No |
| Address one node for a patch | Awkward | Possible | ✓ /items/0/id | No | Direct edit |
| Script filters such as ?(@.id==1) | Rejected (preventEval) | ✓ select() | No | const / enum | No |
| Ask a live API for a subset | No - local document only | No | No | No | No |
| Runs in this browser, no upload | ✓ | Local CLI | Library | Schema page | Editor page |
GraphQL is missing from the grid on purpose: it is a server protocol, not a client-side walk of a document you already pasted. Regex over minified JSON is worse than any of the columns above. If you only need indentation, stay on the formatter.
Common JSONPath Errors and Honest Limits
These are the failures this page will not hide, plus the jobs it will not pretend to do.
- Invalid JSON first. Trailing commas, comments, and unquoted keys fail in
parseJsonDocumentbefore JSONPath runs. Repair the draft or use the JSON5 validator if the dialect is intentional. - Empty path. A blank JSONPath is rejected with an explicit prompt to enter something like
$.items[*].id. - Script filters.
$.items[?(@.id==1)]may throw or return nothing becausepreventEvalis on. That is a security choice, not a missing feature checkbox. - Library-specific unions and slices. If a fancy path errors, simplify it. Dot keys,
[*], numeric indexes, and$..cover most API debugging. - Always an array. One match still wraps. Tests that expect a bare string will fail until you take
[0]in your own code. - Not a transform. You cannot rename keys, drop fields, or emit a patched clone. Use the editor or jq.
- Not SQL or GraphQL. No joins, no live schema, no variables besides the path string.
- Numbers are IEEE-754. Huge integer ids can round in JavaScript before the path reads them. Keep those ids as strings in the source.
- Large documents stall the tab. Walking a multi-megabyte tree is an in-memory walk. Cut a slice locally or inspect stats on the JSON file processor instead of querying a 40 MB log in the textarea.
Privacy & Security - 100% Browser-Side Querying
JSONPath matching runs entirely in your browser with jsonpath-plus and preventEval: true. The document and the path are never posted to a query API. That makes the page usable on payloads that include customer records, tokens, or internal catalogs - with the usual caveat that browser extensions, shared machines, and screenshots can still see the textarea. Prefer synthetic data when the real document is a production secret.
Your JSON and JSONPath are auto-saved to localStorage under a key unique to this tool for up to 30 days so you can resume the same catalog. The draft never leaves this device. Click Clear to restore the Ada/Grace sample. Clearing site data for this origin deletes the saved query as well.
Frequently Asked Questions
What is JSONPath?
JSONPath is a query language for JSON, analogous to XPath for XML. A path such as $.items[*].id walks from the root, into items, over every array element, and reads id. This page uses jsonpath-plus with preventEval so the path cannot run arbitrary JavaScript.
How does the default query $.items[*].id work?
The sample document is a catalog with two objects: Ada (id 1) and Grace (id 2). The default path $.items[*].id returns [1,2]. Path $.items[0].name returns ["Ada"]. Results are always wrapped as a JSON array.
Is JSONPath the same as jq?
No. jq is a programming language that can map, reduce, and define functions. JSONPath only selects nodes. There is no reduce, no custom functions, and no file globbing. Use jq on your machine when you need a full transform language.
Does this JSON query tool upload my document?
No. Matching runs entirely in the browser. The document and path stay in localStorage on this device for up to 30 days and are never sent to a server.
Why are filters such as $.items[?(@.id==1)] rejected?
Historical JSONPath engines evaluated filter scripts with JavaScript eval. That is unsafe in a web page. This tool sets preventEval and fails paths that require executing an expression. Use an index such as $.items[0] instead.
Can I transform the JSON document, not only query it?
The output is the list of matches, pretty-printed as JSON. It is not a patch engine and it does not rewrite the source. Edit the original on the JSON editor, or compare versions on JSON compare.
What does wrapping matches as an array mean?
A single match and many matches have the same shape: a JSON array. $.items[0].name returns ["Ada"], not the bare string Ada. That makes copy-paste into tests predictable.
Does recursive descent such as $..id work?
Yes. $..id is a path, not a script, so it still runs with preventEval on. It collects every id nested anywhere under the root and returns them as an array.
Can I query JSON5, JSONC, or JSON with comments?
No. The document must parse as RFC 8259 JSON first. Comments, unquoted keys, and trailing commas fail before the path runs. Repair the draft on JSON repair or validate JSON5 on the JSON5 validator, then query the strict JSON.
Is this JSONPath query tool free?
Yes. There is no registration, no usage cap, and no premium filter pack. Query as much JSON as your browser can hold in memory.
Related JSON Tools
Querying is one step. These sibling tools cover edit, diff, repair, and validation on the same origin:
- JSON editor - change values in text, tree, or table mode after you know which nodes matter.
- JSON compare - deep-diff two documents by path when selection is not enough.
- JSON repair - turn unquoted keys and trailing commas into RFC 8259 before a path can run.
- JSON formatter - pretty-print or minify a valid document without querying it.
- JSON viewer - expand a tree when you want to browse, not select.
- JSON Schema validator - check a contract instead of extracting fields.
- JSON file processor - stats and pretty-print for large files in a worker.
- JSON validator - syntax-only RFC 8259 check when the path should not run yet.
Related Tools
Discover more free developer tools that might interest you.
JSON Formatter
Format and validate JSON data
Use ToolJSON Viewer
View JSON data in a tree structure
Use ToolJSON Minifier
Minify JSON data to reduce size
Use ToolJSON Editor
Edit JSON in text, tree, and table modes. Works offline in the browser
Use ToolJSON Compare
Diff two JSON documents path by path
Use ToolJSON Repair
Repair malformed JSON into valid RFC 8259 text
Use Tool