JSONPath Tester
Test JSONPath selectors against pasted or loaded JSON locally, then review matched values, paths, JSON Pointers, type counts, charts, syntax notes, and reusable code snippets.{{ primaryOutput || emptyOutputText }}
| Index | Path | Pointer | Type | Depth | Preview | Copy |
|---|---|---|---|---|---|---|
| {{ row.index }} | {{ row.path }} | {{ row.pointer }} | {{ row.type }} | {{ row.depth }} | {{ row.preview }} |
{{ codeSnippet }}
| Selector | Use | Example | Support | Copy |
|---|---|---|---|---|
| {{ row.selector }} | {{ row.use }} | {{ row.example }} | {{ row.support }} |
{{ diagnosticJson }}
Introduction:
JSONPath is a query syntax for selecting values inside a JSON document. Instead of reading a large payload by hand, a selector can ask for every book title, every price value, the first item in an array, or every nested value with a particular member name.
That makes JSONPath useful for API samples, log records, monitoring payloads, test fixtures, and configuration reviews. A selector that works on one payload may return nothing on another because the shape changed, a key is missing, an array index moved, or the evaluator handles filters differently.
JSONPath results should be read as node selections, not as schema validation. A successful query proves that the expression can be evaluated against the current JSON value. It does not prove that the payload follows a contract, that a missing match is an error, or that another JSONPath library will serialize every path in the same way.
Filters deserve extra care because they compare values while walking arrays or objects. They are convenient for questions such as "book price below 10," but they also create the largest compatibility gap between evaluators, especially when examples are copied into application code.
How to Use This Tool:
Start with a small representative payload, then expand the expression once the first match count and ledger rows look right.
- Paste one JSON value into JSON source, choose Browse JSON, drop a
.jsonor.txtfile, or load Sample. The file reader accepts JSON or text files up to 2 MB. - Enter a JSONPath expression that starts at
$. The quick inserts add common fragments such as.*,..price,[*],[0:2], and[?()]. - Choose Result artifact. Use Values as lines for a quick copy, Path = value lines when reviewing context, Paths only or JSON Pointers only for selector evidence, or JSON array when the matched values should remain structured.
- Set Evaluator policy. JSONPath Plus safe filters supports filter expressions, No script filters disables filter evaluation, and Basic local selectors only keeps to simple root, child, index, wildcard, recursive descent, slice, and union selectors.
- Open Advanced when large outputs need a Display cap, formatted values need a different JSON indent, or Code snippet should show a JavaScript, Python, Java, Go, or PHP starter example.
- Read the summary before copying output. JSON issue means the source did not parse; Expression issue means the selector could not be evaluated under the selected policy; No matches means the expression was valid but returned an empty nodelist.
- Use Match Ledger, Match Shape, and Syntax Notes to confirm paths, pointers, value types, depth, and support notes before reusing the selector in tests or application code.
Interpreting Results:
Matched means the expression returned one or more JSON nodes. The summary count is the total match count, while Display cap limits how many rows and primary output lines are shown for broad selectors.
No matches is not automatically a failure. It can mean the payload lacks the requested key, a filter condition is false for every item, an array index is outside the current array, or the expression is aimed at a different version of the payload.
Matched Values is the copy-focused artifact. Match Ledger is the audit view because it keeps the JSONPath-style path, JSON Pointer, type, depth, and value preview together. Match Shape helps spot an unexpectedly mixed result, such as a selector that returns both objects and numbers.
The false-confidence risk is evaluator mismatch. A selector with only child names and indexes is more portable than a filter-heavy selector. When a copied code snippet will be used in another language, rerun the same sample in that target library and compare the matched values, not just the expression text.
Technical Details:
A JSON value forms a tree of nodes. Objects add named child nodes, arrays add zero-based indexed child nodes, and primitive values such as strings, numbers, booleans, and null become leaves. JSONPath starts at the root value with $ and applies one segment after another to produce a nodelist.
Selectors do not mutate the JSON source. A child selector narrows to a member, an index selector narrows to an array item, a wildcard expands to all children, recursive descent searches through descendants, a slice selects a range of array items, a union combines named or indexed choices, and a filter keeps children that pass a condition.
Transformation Core:
| Stage | Rule | Review check |
|---|---|---|
| Parse source | The JSON source must parse as one JSON value before any selector can run. | Fix JSON issue messages before trusting match output. |
| Read expression | The expression starts at $ and is split into root, child, index, wildcard, slice, union, recursive, and filter segments. |
The selector rail should resemble the intended path shape. |
| Evaluate selectors | Each segment consumes the current nodelist and returns the next nodelist. | An empty nodelist is valid when no node satisfies the next segment. |
| Apply policy | Safe filters allow filter conditions, no-script mode rejects filter evaluation, and basic mode supports only simple local selectors. | Use the evaluator badge and Syntax Notes before copying expressions elsewhere. |
| Prepare evidence | Matched nodes are summarized as values, paths, JSON Pointers, value types, depth, and chart rows. | Use Match Ledger when a selector needs reproducible evidence. |
Selector Support Map:
| Selector | Meaning | Support note |
|---|---|---|
$ |
Root value. | Required starting point. |
.key or ['key'] |
Named object member. | Bracket form handles spaces and punctuation in member names. |
[0] or [-1] |
Array item by zero-based index, with negative indexes counted from the end where supported. | Out-of-range indexes return no node rather than inventing a value. |
[*] |
All children of an array or object. | Broad wildcards can produce many ledger rows. |
..price |
Recursive descent to descendants with the requested member name. | Useful for inspection, but easy to overmatch in large payloads. |
[0:2] |
Array slice from start up to, but not including, end. | Basic mode supports simple positive-step slices. |
[0,2] |
Union of selected indexes or keys. | Order and duplicate handling can vary by evaluator. |
[?(@.price < 10)] |
Filter children by a condition. | Requires the safe-filter evaluator; no-script and basic modes reject filters. |
JSON Pointer evidence is different from JSONPath evidence. A pointer uses slash-separated reference tokens such as /store/book/0/title, with ~0 for a literal tilde and ~1 for a literal slash inside a key. That makes pointers useful for exact node evidence even when the original selector used a wildcard or filter.
Result Evidence:
| Result field | Meaning | How to verify it |
|---|---|---|
| Total matches | Number of nodes returned by the current expression. | Compare with shown rows when Display cap is active. |
| Path | JSONPath-style route to the matched node. | Use it to understand which branch of the source produced the value. |
| Pointer | JSON Pointer route to the same matched node. | Use it for tools and specs that expect pointer syntax. |
| Type | Matched value kind: string, number, object, array, boolean, or null. | Check for mixed types before assuming a single output shape. |
| Depth | How far the matched node sits below the root value. | Unexpectedly deep matches may indicate that recursive descent matched more than intended. |
Privacy Notes:
Pasted JSON and selected files are evaluated in the browser page, and selected files are read into the text area rather than uploaded for evaluation. The page can still load its evaluator and chart code from third-party content hosts, and copied output, downloaded files, screenshots, and diagnostic JSON can contain source data. Keep secrets out of examples unless local policy allows that exposure.
Worked Examples:
Filter book titles by price
Using the sample payload with $.store.book[?(@.price < 10)].title and JSONPath Plus safe filters should show 2 matches. Matched Values contains the two title strings, while Match Ledger shows the exact book paths and pointer rows that produced them.
Inspect every price field
The expression $..price searches through descendants and returns book prices plus the bicycle price in the sample. Set Result artifact to Paths only when the goal is to confirm where prices live before choosing a narrower selector.
Keep a portable basic selector
In Basic local selectors only, $.store.book[0:2].title stays inside simple child and slice behavior and returns the first two book titles. The same mode rejects [?()] filters, so an Expression issue is expected until the evaluator policy is changed.
Troubleshoot empty or broken output
If a source is missing a comma or closing brace, the summary reports JSON issue and no match evidence should be trusted. If the JSON parses but $.store.magazine[*].title returns No matches, the selector is valid but the sample has no magazine branch.
FAQ:
Does a match mean the JSON is valid for my API?
No. A match means the source parsed as JSON and the expression selected nodes. API schemas, required fields, business rules, and authentication rules must still be checked separately.
Why did I get no matches?
The expression evaluated successfully but returned an empty nodelist. Check member names, array indexes, filter conditions, and whether recursive descent is aimed at the intended branch.
Why does a filter work in one mode and fail in another?
Filters require an evaluator policy that allows filter conditions. No script filters and Basic local selectors only reject filter evaluation, so choose JSONPath Plus safe filters when expressions use [?()].
Will this expression behave the same in every language?
Not always. Simple child and index selectors are usually easier to move between libraries, while filters, unions, recursive descent, and path serialization deserve a comparison run in the target language.
Why show both a path and a pointer?
The path shows JSONPath-style evidence, while the pointer gives a slash-separated JSON Pointer route to the same node. Pointer rows are useful when another tool expects pointer syntax.
Why was my selected file rejected?
The file picker accepts JSON and text files only, and the browser-side reader rejects files larger than 2 MB. Paste a smaller sample or reduce the fixture before testing the expression.
Glossary:
- JSONPath
- A selector syntax for finding values inside a JSON value.
- Root value
- The whole parsed JSON value, represented by
$. - Selector
- A JSONPath part that selects child nodes, descendant nodes, array items, or filtered values.
- Nodelist
- The ordered set of JSON nodes returned by a selector step or full expression.
- Filter expression
- A condition inside
[?()]that keeps only matching array or object children. - Recursive descent
- A selector such as
..pricethat searches through descendants instead of one direct child level. - Slice
- An array range selector such as
[0:2]. - JSON Pointer
- A slash-separated route such as
/store/book/0/titlethat identifies a specific JSON value.
References:
- RFC 9535: JSONPath: Query Expressions for JSON, Internet Engineering Task Force, February 2024.
- RFC 6901: JavaScript Object Notation (JSON) Pointer, RFC Editor, April 2013.
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format, RFC Editor, December 2017.
- JSONPathOptions, JSONPath Plus documentation.