JSONPath Tester

Matches found—
First match type—
First match—

How JSONPath Tester is calculated: $ is the root; .name picks a key, [0] picks an index, [*] picks everything, and .. searches every level below. Each step narrows the matches.

What is a JSONPath tester?

A JSONPath tester evaluates a JSONPath expression against a JSON document and shows every value it matches. JSONPath is a query language for JSON: $.store.book[*].title means "starting at the root, go into store, then book, take every item, and read its title". The default JSON here is a small book store, and that expression finds 2 matches — Dune and Foundation.

The need comes up whenever a JSON document is too big to read by eye. An API returns a nested object with hundreds of keys, and you need one value buried three levels down. A JSONPath expression names the path to it, and the tester shows the value at once, instead of you scrolling through the whole document.

This tester supports the common subset: $ for the root, .name for a key, [0] for an index, ['name'] for a quoted key, [*] for every item, and .. for recursive descent through every level. Filter expressions such as [?(@.price < 10)] are not supported — the supported syntax is listed in the formula, and anything outside it reports an error rather than guessing.

How JSONPath works

An expression is a path of steps, read left to right. $ is the root of the document. Each step narrows the current set of values: .store keeps only the store key, .book keeps only the book key inside it, [*] expands the array into its items, and .title reads the title of each item. The default expression has four steps after the root, and ends with 2 matches.

The wildcard [*] is the step that multiplies matches. Without it, $.store.book gives one value — the whole array. With it, $.store.book[*] gives two values — the two book objects — and .title then reads the title of each. The match count is the first thing to check: if it is 0, some step in the path found nothing.

Recursive descent, written .., searches every level below the current value. $..title finds every title anywhere in the document, however deeply nested, which is useful when you know the key name but not where it lives. The result is the same 2 matches for the default document, because both titles sit under book.

Recursive descent is the step that surprises people, because it searches everywhere rather than following a path. A double dot followed by a key, such as $..title, finds every title in the document no matter how deep it sits — in the root, in a nested object, or inside an array three levels down. That is useful when the shape of the document is unknown, but it is also slow on a large document, because it visits every value. Use it to explore, and use a precise path once the shape is known.

The steps, explained

Dot notation is the simplest step: .store means the key called store. It works for keys that are plain words. A key with a space or a dash needs bracket notation instead: ['my key'] reads the key called "my key", which dot notation cannot spell.

Bracket notation with a number picks an array index: book[0] is the first book, Dune, and book[1] is Foundation. Indexes start at 0, as in most programming languages. A negative index is not supported by this tester — use a positive index, or the wildcard to take everything.

The wildcard [*] works on arrays and on objects. On an array it gives every item; on an object it gives every value. It is the step to use when you want all of something — all book titles, all prices, all values under a key — without naming each one.

Bracket notation is the step to reach for when a key has a character that dot notation cannot express. A key with a space, a dash, or a dot in its name cannot be written after a dot, because the dot would be read as a step separator. Brackets solve that: $['my key'] reads the key called my key, and $['a.b'] reads the key called a.b rather than the key a followed by the key b. The tester accepts both notations, and the choice is a matter of which one the key's spelling allows.

A worked example: querying a book store

Take the default JSON: a store with a book array of two books — Dune at 19 and Foundation at 15 — and an owner called Ada. The expression $.store.book[*].title walks down to the books, expands both, and reads each title. The result is 2 matches, both strings, the first of which is "Dune".

Change the expression to $.store.book[0].price and the result is one match, a number, 19 — the price of the first book. Change it to $..price and the result is two matches, 19 and 15, because recursive descent finds the price key in both books. Change it to $.owner and the result is one match, the string Ada.

Try a miss to see the boundary: $.store.book[*].author finds 0 matches, because the books have no author key. A match count of 0 means some step found nothing — read the path from the left and check each key against the document until you find the step that went wrong.

Who uses a JSONPath tester, and why

API developers are the main users. A response comes back as nested JSON, and the developer needs to know whether the data they want is at $.data.items[0].id or at $.items[0].id. Testing the expression here answers that in seconds, before the code is written.

Testers and QA engineers are the second group. An API test asserts that a response contains a value at a given path, and the tester is where the path is worked out. Getting the path right here means the test passes for the right reason, not by accident.

Data analysts are a third group. A JSON export from a tool needs one column pulled out — all the titles, all the prices — and a JSONPath expression with a wildcard does it. A JSON to CSV converter turns the whole document into a spreadsheet when the whole document is needed.

Test engineers are a third group. An API test that checks a response needs to pull one value out of a large JSON document, and a JSONPath expression is the line that does it. The tester is where that expression is written and checked: paste a real response, type the path, and the matches show whether the path finds the value the test will assert on. A path that finds nothing in the tester will find nothing in the test, and the tester finds that out in seconds.

JSONPath vs other JSON tools

JSONPath queries data; other JSON tools change it or check it. The JSON formatter on this site tidies JSON so it can be read, and a JSON validator checks whether it parses. Use the formatter to read the document, and this tester to pull values out of it.

The closest relative is the JSON Schema validator, which checks whether a document matches a shape. A schema says what the document should look like; a JSONPath expression says which value to take from it. Both work on the same document, and both are part of testing an API.

A JSON to CSV converter flattens a whole array into a table, which is the right tool when you need every row. JSONPath is the right tool when you need one value, or one column, from a document too big to flatten by hand.

Common JSONPath mistakes

The first mistake is a missing step. $.book[*].title fails when the books live under $.store.book — the path must spell every level, starting at the root. Read the document's structure first, then write the path to match it.

Second: forgetting that indexes start at 0. book[1] is the second book, not the first. The first book is book[0], and book[2] on a two-book array finds nothing at all.

Third: using dot notation for a key with a special character. A key called "my-key" cannot be written as .my-key, because the dash is not a valid character in a dot step. Use bracket notation with quotes: ['my-key'].

Fourth: expecting filters. Expressions such as [?(@.price < 10)] are part of full JSONPath, but this tester does not support them — it reports an error instead. Use the wildcard to take everything, and filter the matches yourself, or use a full JSONPath library for filter queries.

A second mistake is forgetting the dollar sign at the start. A path that starts with .store.book reads as a relative path, and the tester will report that it cannot parse it, because every path in this tool starts at the root. The dollar sign is the root, and everything after it is a step from there. The error message says the path is invalid, but the fix is one character: put a $ at the front and the same path works.

How to use this JSONPath tester

Paste your JSON into the first box — the default is a small book store — and type your expression into the second. The default expression, $.store.book[*].title, finds 2 matches. The matches appear as a JSON array in the box below, with the count, the first match's type, and the first match above it.

To copy the matches, use the Copy button next to the output box. To test another expression, edit the second box and watch the results update live. A match count of 0 means some step found nothing — read the path from the left and check each key against the document.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — your JSON never leaves your device. It works offline once the page has loaded.

Paste the JSON first, then type the path, and the matches appear underneath with their values. The match count tells you how many values the path found, and the list shows each one with its path, so a wildcard result is easy to read. To test a path you are unsure about, start with a short one — $.store, then $.store.book, then $.store.book[0] — and watch the matches narrow at each step. When the path returns exactly the values you expected, copy it into the code that will use it.

Frequently Asked Questions

Starting at the root ($), go into the store key, then the book key, take every item in the array ([*]), and read the title of each. On the default JSON it finds 2 matches: Dune and Foundation.

Both read the key called name. Dot notation works for plain keys; bracket notation with quotes works for any key, including keys with spaces or dashes, such as ['my-key'], which dot notation cannot spell.

Recursive descent: it searches every level below the current value. $..title finds every title anywhere in the document, however deeply nested. It is useful when you know the key name but not where it lives.

No. This tester supports the common subset: dot, bracket, index, wildcard, and recursive descent. Filter expressions are part of full JSONPath but are not supported here — the tester reports an error instead of guessing.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.