💻 Coding

JSON Path Tester

Paste JSON and a JSONPath expression to see exactly which values it matches, live as you type.

Presets:
$.* (All root children) $..* (Recursive all) $..price (All prices) $.store.book[0] (First book) $.store.book[-1] (Last book)


    
0
Matches

How to Query, Filter, and Evaluate JSONPath Expressions Online?

Quick Answer: To query and evaluate JSONPath expressions, paste your JSON document into the left editor and type a valid path expression (such as $.store.book[*].title or $..price) into the query input. The client-side evaluator parses the AST, traverses nested structures, and extracts matching values into a clean, formatted results pane with real-time match counters and zero server uploads.

As microservices architectures, cloud platforms, and event-driven data streaming pipelines have matured, JSON has become the ubiquitous format for payloads, telemetry, and system states. However, complex real-world JSON documents are rarely flat. They contain deeply nested structures, variable-length arrays, polymorphic dictionaries, and heterogeneous schema definitions. Extracting specific attributes or filtering sub-collections manually by writing imperative traversal code is brittle, tedious, and prone to null pointer exceptions.

JSONPath solves this challenge by providing a declarative, expressive query language designed specifically for navigating JSON object hierarchies. Analogous to XPath in the XML ecosystem, JSONPath lets software engineers, QA automation specialists, data analysts, and DevOps teams isolate exact scalar values, arrays, and sub-trees using concise, readable string expressions.

The Evolution of JSON Querying: Stefan Goessner to IETF RFC 9535

JSONPath was originally conceptualized by Stefan Goessner in 2007 as a lightweight equivalent to XML XPath for JSON documents. While Goessner's original design proved immensely popular across libraries in Python, JavaScript, Java, and Go, it lacked a formal international specification. Consequently, different programming language implementations introduced subtle discrepancies regarding array slice indexing, script filter evaluations, recursive descent behavior, and handling of special characters.

In February 2024, the Internet Engineering Task Force (IETF) formally published RFC 9535 ("JSONPath: Query Expressions for JSON"). RFC 9535 establishes a standardized, deterministic grammar for JSONPath syntax, defines unambiguous query semantics, standardizes normalized path expressions, and resolves long-standing cross-platform divergences. This interactive tester adheres to the core structural principles of RFC 9535, ensuring queries tested here behave predictably across modern cloud and enterprise runtimes.

Core Syntactic Grammar and Lexical Tokenization

A JSONPath expression consists of a sequence of query segments that define a traversal path from the document root down to target elements. The evaluation grammar is composed of the following structural building blocks:

RFC 9535 JSONPath Operator Syntax Reference

Operator Syntax Name Semantic Function Canonical Example Evaluated Output
$ Root Identifier Represents the root object or root array $ Entire document object tree
.property Dot-Child Selector Selects direct child member on an object $.store.bicycle Bicycle sub-object
['property'] Bracket Selector Selects child member with spaces or hyphens $['store']['book'] Book collection array
[n] Array Index Selects n-th array element (supports negative indices) $.store.book[0] First book object in list
[-1] Negative Index Selects n-th array element counting from the end $.store.book[-1] Last book object in list
[start:end:step] Array Slice Extracts a range of array elements with stepping $.store.book[0:4:2] Elements at indices 0 and 2
[*] Wildcard Selector Selects all elements in array or all values in object $.store.book[*].title Array of all book titles
..property Recursive Descent Recursively finds all keys matching name at any depth $..price All prices across books and bicycles
..* Universal Descent Recursively extracts every scalar, object, and array $..* Exhaustive list of all nested values

Evaluating Candidate Match Sets: Set-Based Traversal

A frequent point of confusion among engineers new to JSONPath is understanding how query segments transform data during multi-stage evaluation. Unlike standard procedural property lookups that navigate a single pointer, a JSONPath engine operates over a candidate set of nodes:

  1. Root Initialization: The evaluation begins with an initial node set containing a single item: the root JSON document ($).
  2. Segment Processing: As the engine encounters each path segment, it evaluates that token against every individual node currently present in the candidate set.
  3. Result Expansion: When a segment yields multiple matches (such as an array wildcard [*] or recursive descent ..), the candidate set expands to contain all extracted matching values.
  4. Downstream Filtering: The next segment in the expression (e.g., .title) then runs across every node in the expanded set independently. Nodes that do not contain the requested property are silently omitted from the downstream set without raising runtime null errors.
  5. Final Aggregation: Once all segments have executed, the resulting nodes are collected and rendered as an ordered JSON array representing the matched output.

Array Slicing Mechanics and Stepping Semantics

JSONPath incorporates array slicing syntax inspired by Python slicing conventions: [start:end:step]. This powerful syntax allows developers to extract specific windows of data from large arrays without writing manual pagination or looping logic:

For example, given a list of ten transactions, the expression $.transactions[0:5] extracts the first five entries, $.transactions[-3:] isolates the three most recent items, and $.transactions[::2] extracts every alternating entry.

Recursive Descent (..) Deep Search: Mechanics and Performance

The recursive descent operator (..) is one of the most flexible yet computationally intensive features in JSONPath. When querying deeply nested microservice configurations, Kubernetes YAML manifests, or MongoDB document collections, you often need to locate specific attributes (such as $..secretKey or $..status) without knowing the exact structural path or nesting depth.

Under the hood, recursive descent performs an exhaustive depth-first or breadth-first traversal of the entire object graph. While highly effective for exploring unknown schemas, developers should exercise caution when executing recursive queries against multi-megabyte payloads in production services. Because the engine must visit every node, branch, and leaf in the tree, algorithmic complexity scales linearly with total document node count (O(N)). For high-throughput production microservices, specifying explicit paths (such as $.data.orders[*].id) is significantly more efficient than open recursive queries.

Defensive Security: Preventing Prototype Pollution

When running client-side JSONPath evaluators inside web browsers, security is a primary architectural requirement. In JavaScript environments, all objects inherit properties from Object.prototype. If an unhardened evaluator naively resolves properties using square-bracket indexing (current[segment]), querying properties like __proto__, constructor, or toString can expose internal runtime mechanics or lead to prototype pollution vulnerabilities.

This JSON Path Tester implements defensive security safeguards. Property lookup routines explicitly verify ownership using Object.prototype.hasOwnProperty.call(node, key). This guarantees queries exclusively match data attributes present in your JSON payload, preventing prototype property exposure and keeping your testing environment secure.

Real-World Engineering Use Cases

JSONPath has been adopted across virtually every major tier of enterprise software engineering:

Zero-Trust Architecture: 100 Percent Client-Side Privacy

Data privacy is guaranteed by design. API responses, customer database records, and server manifests frequently contain confidential credentials, private API keys, user contact details, and proprietary financial data. Many online utility tools transmit your input data to remote analytics servers or backend microservices.

Utility369 executes the entire JSON parsing and JSONPath evaluation pipeline 100 percent locally inside your web browser. No network requests are made, no telemetry logs are created, and no data is cached on external servers. You can disconnect your internet connection or inspect browser network logs to verify complete local isolation.

Frequently Asked Questions

How does chaining a wildcard with another property, like [*].author, work?

The evaluator tracks a list of active matches rather than a single pointer. When [*] executes, it populates the match set with every element in the array. The subsequent .author token then executes against each element independently, collecting results into a new flattened array.

What is the difference between deep recursive descent $..price and $..*?

The expression $..price searches every nested level specifically for object keys matching the name price. In contrast, $..* performs unconditional recursive descent, extracting every scalar, object, and array across all nesting levels.

Why does $.store.book.author fail to match when book is an array?

Under RFC 9535 specifications, dot-notation property access is valid only for objects and never arrays. To query properties inside an array, you must explicitly use array notation like [*].author or [0].author.

Could a JSONPath expression accidentally match prototype properties in JavaScript?

No. The evaluator specifically invokes Object.prototype.hasOwnProperty.call() to ensure only keys originally present in the parsed JSON document match, ignoring built-in properties like toString or constructor.

How do negative array indexes like [-1] work in JSONPath?

Negative array indices count backward from the end of the array. For example, [-1] selects the final element, and [-2] selects the penultimate element, identical to Python and modern JavaScript array semantics.

Is my JSON payload transmitted to any external server during query testing?

No. Both JSON parsing and JSONPath tokenization/evaluation occur 100 percent in memory inside your browser. No data or query parameters are ever uploaded or transmitted.

What is the difference between JSONPath and XPath?

XPath is designed for navigating XML trees with attributes, namespaces, and document order. JSONPath adapts XPath concepts to JSON structures, replacing slash syntax with dot and bracket notations for objects and arrays.

How does array slice notation [start:end:step] operate in JSONPath?

Slice syntax extracts subsets of arrays using Python-style intervals. The expression [0:5:2] starts at index 0, stops before index 5, and steps by 2, returning elements at indices 0, 2, and 4.

Can JSONPath expressions query keys that contain spaces or special punctuation?

Yes. When object keys contain spaces, dots, dashes, or non-ASCII characters, use bracket notation with single or double quotes, such as $['order-id'] or $['first name'].

What is the difference between RFC 9535 JSONPath and legacy Stefan Goessner implementations?

RFC 9535 standardizes JSONPath syntax, removing ambiguity in script evaluations, clarifying slice bounds, defining normalized paths, and eliminating implementation discrepancies across languages.