JSONPath Tester
The JSONPath Tester runs JSONPath queries against your JSON in the browser and shows every match with its full path — filters, slices, recursive descent, and the RFC 9535 functions — with a clickable cheat sheet whose results were produced by this page's own evaluator.
How to Use
- 1
Paste your JSON on the left — or load a sample: the bookstore, an API list response, or a nested config. Invalid JSON is flagged with the parser's error message.
- 2
Type a JSONPath expression starting with $ — try $..book[?(@.price < 10)].title on the bookstore sample. Evaluation is live as you type.
- 3
Read every match with its full path (for example $.store.book[2].title) and its value. A query returns an array of matches — $..price returns all five prices, not one value.
- 4
Click any key in the tree below the editors to fill the expression box with that node's exact path — the fastest way to learn the syntax.
- 5
Use the cheat sheet at the bottom of the page: every expression there is clickable and its result on the bookstore sample is shown next to it.
- 6
Copy the matches as JSON or download them as jsonpath-matches.json. Nothing is uploaded — verify in the DevTools Network tab: zero requests are made.
Frequently Asked Questions
What is JSONPath?
JSONPath vs jq vs JMESPath — when to use each?
Why does my filter not work in another tool?
What is the difference from the JSON Viewer?
What JSONPath does this tester support?
Are filter expressions safe here?
Why does $..price return an array?
How do I get the last item of an array?
Can it handle very large JSON documents?
Is my JSON uploaded anywhere?
Generative Answer & AI Documentation
What is the JSONPath Tester?
The JSONPath Tester evaluates a JSONPath expression against a JSON document and returns every matching node with its full path. Paste JSON (or load a sample — the classic bookstore, an API list response, or a nested config), type an expression starting with $, and the matches appear live as you type: $.store.book[*].author returns all four authors, $..price returns every price at any depth, and $..book[?(@.price < 10)].title returns the two books under $10. Click any key in the tree view and the expression box fills with that node's exact path. The cheat sheet at the bottom of the page lists the supported grammar with the tested result of each expression on the bookstore sample, and matches can be copied or downloaded as JSON. Everything runs in your browser — the document never leaves the tab.
Why use JSONPath Tester offline?
API responses are large and the field you need is buried three levels deep. Reading the whole response to find it is slow, and writing a one-off script for a five-minute question is slower. JSONPath answers the question in one line: $..email pulls every email out of a users array, $..book[?(@.price < 10)] pulls the cheap books, $.store.book[-1:] pulls the last item. The alternative most developers reach for — pasting a production response into a server-side tester — sends real customer data to a third party; this page exists so the same question can be answered without the payload ever leaving the tab. And because JSONPath libraries disagree with each other, this page states its exact grammar and rejects what it does not support, instead of silently returning a wrong answer.
When should you use this tool?
Use it when debugging an API response (find the one field that is null, or the one item whose price is wrong), when writing the query your code will use (prototype it here, then paste the working expression into your Python, JavaScript, or Go code), when learning JSONPath (the cheat sheet's expressions are clickable and their results are shown), or when extracting data from a large document for a report (copy the matches as JSON). Use the JSON Formatter first if the document is minified and unreadable, and the JSON Viewer if you want to read the whole tree rather than select from it. Do not use it to transform data — JSONPath selects nodes, it does not reshape them; for reshaping, use jq on the command line.
Key Benefits
- Live evaluation: every match with its full path appears as you type, with a match count.
- Click any key to get its path: the tree view fills the expression box with the exact path of the node you clicked.
- Match highlighting: matched nodes are highlighted in the tree, so you can see where a query lands in the document.
- Honest RFC 9535 subset: the supported grammar is listed on the page, and unsupported forms are rejected with an error instead of silently mis-evaluated.
- Safe filters: filter expressions run through a hand-written parser — never eval() — so a pasted expression cannot execute code.
- Cheat sheet with tested results: every expression in the table was run by this page's own evaluator on the bookstore sample.
- Copy or download matches as JSON, and three sample documents to start from.
- 100% private: parsing and evaluation are local JavaScript — verify in the DevTools Network tab, zero requests.
Common Use Cases
- Extracting one field from a big API response: $..email on a users array returns every email address without scrolling through the whole response.
- Filtering an array: $..book[?(@.price < 10)] finds the books under $10, and $..book[?(@.category == 'fiction')].title lists the three fiction titles.
- Getting the last item: $.store.book[-1:] returns the final book, and $.store.book[-2:] the last two — negative indexes count back from the end.
- Checking a nested config: $.server.tls.enabled answers whether TLS is on, and $..enabled finds every enabled flag at any depth.
- Prototyping a query for code: test the expression here until it returns exactly the nodes you want, then paste it into your application with confidence.
Developer Notes & Best Practices
The evaluator is hand-written in lib/jsonPathEvaluator.ts — zero dependencies, no jsonpath-plus, no eval(). The query parser reads the expression into segments: child (.key, ['key']), wildcard (.*, [*]), recursive descent (..child, ..*, ..[?(...)]), index ([n], including negative), slice ([start:end:step] with omitted bounds and negative bounds), union (['a','b'], [0,1]), filter ([?(...)]) and a trailing function segment (.length() / .count() / .value()). Filters are lexed and parsed into a small AST (literals, @ and $ paths, length() / count() / value() / match() / search(), comparisons == != < <= > >=, &&, ||, !, parentheses) and interpreted against each candidate node; a comparison against a missing value (Nothing in RFC 9535 terms) is false, never an error. length() returns the length of a string, array, or object; count() counts the nodes a path matches; value() requires exactly one node; match() requires the whole string to match the regex and search() a partial match. Rejected with a clear error: script expressions [(...)], bare words as filter operands, functions outside the five listed, a slice step of 0, and a .length() segment anywhere but the end. Verified against the bookstore sample in Node (65 assertions, all passing): $..price returns [8.95, 12.99, 8.99, 22.99, 19.95], $..book[?(@.price < 10)].title returns Sayings of the Century and Moby Dick, $.store.book[-1].title returns The Lord of the Rings, and $.store.book[0:4:2].title returns Sayings of the Century and Moby Dick. One honest divergence to know: $..* here returns every member value at any depth except the root itself, which matches RFC 9535; some older libraries return a different set for that expression.
The supported grammar — every form, tested on the bookstore sample
| Syntax | What it selects | Result on the bookstore sample |
|---|---|---|
| $ | The whole document | The entire bookstore object |
| $.store.bicycle.color | Child by name | "red" |
| $['store']['bicycle']['color'] | Child by quoted name | "red" |
| $.store.book[*].author | Wildcard — every book's author | 4 authors |
| $..price | Recursive descent — every price | [8.95, 12.99, 8.99, 22.99, 19.95] |
| $..author | Recursive descent — every author | 4 authors |
| $.store.book[0] | Index — first book | Sayings of the Century (object) |
| $.store.book[-1].title | Negative index — last book | "The Lord of the Rings" |
| $.store.book[0:2].title | Slice — first two titles | ["Sayings of the Century", "Sword of Honour"] |
| $.store.book[0,2].title | Union — books 0 and 2 | ["Sayings of the Century", "Moby Dick"] |
| $..book[?(@.price < 10)].title | Filter — books under $10 | ["Sayings of the Century", "Moby Dick"] |
| $.store.book.length() | Function — how many books | 4 |
Filter functions (RFC 9535)
| Function | What it returns | Example |
|---|---|---|
| length(x) | Length of a string, array, or object | [?(length(@.title) > 15)] — long titles |
| count(path) | How many nodes a path matches | [?(count(@..*) > 3)] |
| value(path) | The value of a path matching exactly one node | [?(value(@.price) < 9)] |
| match(str, regex) | True when the whole string matches | [?(match(@.author, '.*Tolkien'))] |
| search(str, regex) | True when any part matches | [?(search(@.title, 'Moby'))] |
JSONPath vs jq vs JMESPath
| Tool | Best for | Runs where |
|---|---|---|
| JSONPath | Selecting nodes with a short expression | Browser (this page), most languages |
| jq | Selecting, transforming, and reshaping JSON | Command line, scripts, pipelines |
| JMESPath | Querying JSON inside AWS services | AWS CLI, boto3, Azure CLI |
- Start from $ and add one segment at a time: $.store, then $.store.book, then $.store.book[*].title — when a query returns nothing, the last segment you added is the suspect.
- Use $..key to find a field when you do not know where it lives, then replace it with the exact path once you know — recursive descent is for exploration, exact paths are for code.
- Test filters on the sample before your real data: $..book[?(@.price < 10)] shows the shape of a working filter, and the error message tells you exactly what this evaluator rejected.
- Remember a query returns a list of matches, even for one node: take the first match in your code, or use value() in a filter when the path must match exactly one node.
- Copy the working expression out of the page and into your code, not the matches: the expression is the reusable part, the matches are today's data.
- When a query works here but not in another tool (or the reverse), check the grammar table first — filters and negative indexes are where libraries diverge, and this page documents its exact subset.
Common Mistakes
- Forgetting the leading $: a query must start with the document root — store.book is not a query, $.store.book is.
- Expecting one value instead of a list: $..price returns an array of five prices, not a single number — take the first match or use value() when you need one value.
- Using a bare word in a filter: [?(@.price < foo)] fails because foo is neither a literal, a path, nor a function — quote it as 'foo' if it is a string, or use a number.
- Writing a script expression: [(0)] and similar forms are rejected — use an index [0] or a filter [?(...)] instead.
- Assuming a filter that works in one library works in all: JSONPath was unstandardised for 17 years and libraries still diverge on filters and negative indexes — test the query in the tool that will run it.
- Pasting a production response into a server-side tester: this page exists so you do not have to — the document here never leaves the tab.
Limitations
This evaluator implements the RFC 9535 subset listed on the page — it is not a complete RFC 9535 implementation and it is not jsonpath-plus. Script expressions [(...)] are rejected, as are functions outside length(), count(), value(), match(), and search(), bare words as filter operands, and a .length() segment anywhere but the end of the query. A filter that references a missing value compares as false rather than erroring, which follows RFC 9535's Nothing semantics but can surprise users who expect an error. Evaluation is in-memory: documents up to a few megabytes are fine, but documents of tens of megabytes may freeze the tab — for those, query in chunks or use jq. The tree view expands the first two levels by default and has no search box; for very large documents, collapse branches and expand only the path you need. $..* returns every member value at any depth except the root, per RFC 9535 — some older libraries return a different set for that expression, so do not copy that particular query between tools without testing it.
Structured Input/Output Example
$.store.book[?(@.price < 10)].title
[
{ "path": "$.store.book[0].title", "value": "Sayings of the Century" },
{ "path": "$.store.book[2].title", "value": "Moby Dick" }
]Related Tools
JSON Formatter
JSON formatter: turn minified or messy JSON into readable, indented output. 2 spaces, 4 spaces, or tabs — paste, click Format, copy or download.
JSON Viewer
JSON viewer for inspecting API responses as a collapsible, syntax-colored tree. Expand the branches you need, collapse the rest — free, 100% offline.
JSON Validator
JSON validator: paste JSON and click Validate for a verdict — valid or broken, with the line and column of the first syntax error. Strict RFC 8259.
JSON Schema Validator
Validate JSON data against a JSON Schema — does your object match the required shape? Every violation listed with its path and a fix hint. Free, offline.
JSON to TypeScript
Convert any JSON object or array into clean TypeScript interfaces or type aliases in seconds — 100% offline, nothing uploaded.
Mock Data Generator
Mock data generator: build realistic fake users, products, and orders with a seeded schema builder and export JSON, CSV, SQL, or TypeScript — 100% offline.
Color Palette Generator
Color palette generator: one base color in — a 5-color harmony palette plus a 50–950 Tailwind scale. Lock, shuffle, copy HEX/RGB/HSL, export CSS or JSON.