Codepackr / validators / JSONPath Tester

JSONPath Tester

Evaluate JSONPath queries ($..key, store.book[*]) against JSON structures.

Client-Side Execution & Privacy Guarantee

This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.

JSONPath is a query language for selecting nodes from a JSON document. CodePackr's JSONPath Tester lets you write an expression, supply a document, and instantly see every matching value together with the path that located it.

The tester supports the most widely used operators: root $, child and recursive descent, array slices and filters, and wildcards. Results are shown as a list of values so you can verify that a query extracts exactly the data you intend before embedding it in code.

Core path operators

The expression begins with $ which refers to the root. A dot or bracket selects a child: $.store.book or $['store']['book']. The double-dot .. performs a recursive descent, matching the key at any depth.

Array indices are zero-based. The wildcard * matches every element or every property. Slice notation [start:end:step] works on arrays the same way it does in many programming languages.

Filters and predicates

A filter expression inside brackets [?()] keeps only elements that satisfy a condition. Comparisons use @ to refer to the current node. Common predicates include equality, numeric comparisons, and existence checks.

Filters can be combined with logical operators. Because the implementation follows a common subset of JSONPath, very complex script expressions may differ from a particular library; test the exact query you will use in production.

Reading the results

Each match is reported with the selected value and the normalized path that reached it. Multiple matches appear in document order. An empty result list means the path matched nothing; check spelling of keys and the presence of the expected structure.

When a path selects an object or array, the entire subtree is returned. Use a more specific path or a filter if you need only a subset of fields.

When to use this tool

  • You need to extract a list of values from a nested API response without writing temporary code.
  • You are learning JSONPath and want to see how each operator changes the result set.
  • A query returns unexpected nodes and you want to inspect the exact paths that matched.
  • You are writing documentation or tests that include JSONPath expressions and need verified examples.
  • You want to confirm that a path is resilient to missing optional fields before deploying it.

How to use the JSONPath Tester

  1. Paste a valid JSON document into the data area.
  2. Enter a JSONPath expression in the query field.
  3. Run the query to see the list of matching values and their paths.
  4. Refine the expression by adding filters, indices, or recursive descent as needed.
  5. Copy a successful expression for use in your application or test suite.
  6. If the document itself is invalid, fix it first with a JSON validator.
  7. Try both positive and negative cases to ensure the path does not over- or under-select.

Worked examples

Select all book titles

Input
Document: {"store":{"book":[{"title":"Refactoring"},{"title":"Clean Code"}]}}
Path: $.store.book[*].title
Output
["Refactoring", "Clean Code"]

The [*] wildcard iterates every element of the book array and then selects the title property.

Recursive search for a key

Input
Document: {"a":{"id":1,"nested":{"id":2}},"b":{"id":3}}
Path: $..id
Output
[1, 2, 3]

The .. operator finds every property named id regardless of nesting depth.

Common mistakes and tips

  • Always start with $ so the expression is absolute; relative paths are not supported.
  • Quote keys that contain special characters or spaces using bracket notation.
  • Filters are evaluated against the current node; use @.field rather than a full path inside the predicate.
  • An empty array result is not an error; it simply means no nodes matched.
  • Test the same path against a document that lacks the expected structure to confirm graceful handling.

Frequently asked questions

Which JSONPath dialect does the tester implement?

It implements a widely supported subset including $, .., *, filters, and slices. Advanced features that differ between libraries may not be present.

Why does my path return an empty list?

The key names or array indices do not match the document. Check spelling and confirm the structure with a formatter.

Can I use script expressions inside filters?

Basic comparisons are supported. Complex JavaScript expressions inside filters are not evaluated for safety and portability.

Does the tool modify the original document?

No. It only reads the document and returns selected values.

Is the data uploaded?

No. Evaluation happens entirely in your browser.