JSONPath Tester - Query JSON Data
Extract specific data from complex JSON documents using powerful JSONPath expressions. Test queries instantly without writing code.
JSON Input
JSONPath Expression
Examples: $.store.book[*].title | $..author | $.store.book[?(@.price < 10)]
Query Result
Quick Reference Examples
🔒 Your Privacy is Our Priority
JsonifyPro.com is a 100% client-side tool. All data validation, formatting, and conversion happens directly in your browser. We do not see, log, or transmit your data anywhere. Your API responses and sensitive data remain completely private.
What is JSONPath?
JSONPath is a query language for JSON that allows you to extract specific data from complex, nested JSON structures using concise path expressions, similar to how XPath queries XML documents. In modern web development, APIs often return large, deeply nested JSON responses containing far more data than any single use case requires. Instead of writing verbose JavaScript code to manually navigate through objects and arrays—checking for existence of properties, handling undefined values, and iterating through nested structures—JSONPath provides a declarative syntax that expresses exactly what data you want to extract.
The fundamental concept is the path expression: a string that describes the route from the root of the JSON document to the data you're interested in. The simplest path is $.propertyName, which retrieves the value of "propertyName" from the root object. The dollar sign ($) always represents the root of the document. From there, you can navigate deeper: $.user.address.city traverses from root, to the "user" object, to its "address" object, to the "city" property. This dot notation will be familiar to any JavaScript developer—it mirrors property access syntax.
Where JSONPath becomes powerful is in handling arrays and performing queries across collections. The wildcard operator (*) retrieves all elements: $.users[*].email extracts email addresses from all user objects in the users array, returning a new array of just the email values. Filter expressions allow conditional selection: $.products[?(@.price < 100)] returns only products with price less than 100. The recursive descent operator (..) searches for properties at any depth: $..phoneNumber finds all phoneNumber properties throughout the entire document, regardless of nesting level.
JSONPath is essential for API testing and development. When testing API endpoints, you need to verify that specific fields exist with correct values. Rather than writing custom validation code for each endpoint, JSONPath expressions concisely specify what to check: assert that $.response.status equals "success", verify that $.data.items[*].id returns an array with the expected length, confirm that $..error returns an empty array (no errors anywhere in the response). Testing frameworks like REST Assured, Postman, and API testing libraries incorporate JSONPath for exactly this purpose.
How to Use the JSONPath Tester
Using the JSONPath Tester is designed for rapid experimentation and learning. Begin by pasting your JSON data into the JSON Input textarea. This could be an API response you're working with, a configuration file you need to query, test data you're validating, or any JSON document from which you need to extract specific information. The tool validates the JSON automatically—if there are syntax errors, you'll receive clear error messages before attempting any JSONPath evaluation.
Enter your JSONPath expression in the JSONPath Expression field. Start simple if you're learning: $ returns the entire document, $.propertyName returns a top-level property. Use the Quick Reference Examples buttons to see common patterns and understand the syntax. These examples demonstrate fundamental operations: accessing array elements, using wildcards, filtering with conditions, and recursive searches. Clicking an example automatically populates the expression field, letting you immediately see the results and then modify the expression to fit your needs.
Click "Evaluate" to execute the JSONPath query against your JSON data. The result appears in the Query Result textarea, formatted as JSON. If the path matches multiple values, you'll receive an array of results. If it matches a single value, you'll get that value. If nothing matches, you'll receive an empty array. The status bar provides feedback: successful queries show match counts, errors display specific messages about what went wrong (invalid path syntax, property doesn't exist, etc.).
Experiment iteratively by modifying your expression and re-evaluating. This interactive testing is invaluable for understanding how JSONPath works and crafting the precise query you need. Once you've perfected your expression in the tester, you can use it in your code, API tests, or documentation. Use "Copy Result" to copy the extracted data to your clipboard for immediate use in your development workflow.
JSONPath Syntax and Operators
Root and Property Access
Every JSONPath expression begins with the root operator $, representing the entire JSON document. This is analogous to the root directory in filesystem paths or the document root in XPath. From the root, you navigate to properties using dot notation: $.user accesses the "user" property at the root level. Chaining continues indefinitely: $.company.employees.managers.senior traverses through nested objects.
Bracket notation provides an alternative that's required for property names with special characters: $['property-name'] or $['2023-data']. Property names containing spaces, hyphens, or starting with numbers must use bracket notation. You can also use brackets for regular property access: $['user']['email'] is equivalent to $.user.email. In programmatic usage, bracket notation allows variable property names: $[variableName], though this tester uses static expressions.
Array Indexing and Slicing
Arrays use square bracket notation with numeric indices: $.items[0] retrieves the first element (zero-indexed), $.items[2] gets the third element. Negative indices count from the end: $.items[-1] gets the last element, $.items[-2] gets the second-to-last. This is particularly useful when you need the most recent item from an array without knowing its length.
Array slicing uses Python-style slice notation: $.items[start:end]. The expression $.items[0:3] returns elements at indices 0, 1, and 2 (end is exclusive). $.items[1:] returns everything from index 1 to the end, $.items[:5] returns the first five elements. Step values are supported: $.items[0:10:2] returns every second element from 0 to 9. Slicing is essential for pagination testing and extracting subsets of data.
Wildcards and Recursive Descent
The wildcard operator * matches all elements in an object or array. In arrays, $.users[*] returns all user objects—equivalent to the entire array. More powerfully, $.users[*].name projects out just the "name" property from each user object, returning an array of names. This is JSONPath's equivalent of the map operation in functional programming: transform an array of objects into an array of specific property values.
For objects, $.* returns all property values at the current level, ignoring property names. This is less common than array wildcards but useful when you need all values regardless of keys. The recursive descent operator .. is one of JSONPath's most powerful features: $..email finds every "email" property anywhere in the document, at any nesting depth. $..book[*].author finds authors of books no matter how deeply nested the book arrays are in the structure.
Filter Expressions
Filter expressions enable conditional queries using the syntax [?(@.property operator value)]. The @ symbol represents the current item being tested. Common operators include == (equals), != (not equals), < (less than), > (greater than), <= (less than or equal), and >= (greater than or equal). String comparisons use quotes: $.users[?(@.role == 'admin')] returns users with role "admin".
Numeric comparisons don't need quotes: $.products[?(@.price < 100)] returns products under $100, $.scores[?(@.value >= 90)] returns high scores. Filters can reference nested properties: $.users[?(@.address.city == 'New York')]. While some JSONPath implementations support complex boolean logic with && and ||, basic implementations (including many JavaScript libraries) support single conditions. For multiple conditions, chain filters: $.users[?(@.age > 18)][?(@.active == true)].
Practical Query Patterns
Combining operators creates powerful queries. Extract all email addresses from nested user structures: $..users[*].email. Get titles of books costing less than $15: $.store.book[?(@.price < 15)].title. Find all error messages in any part of an API response: $..errors[*].message. Access the first element of every nested array: $..items[0].
For API testing, verify specific response structures: $.meta.pagination.total_pages checks that pagination metadata exists and is accessible. $.data[*].id ensures every data item has an ID. $..created_at finds all timestamp fields. These patterns make API response validation declarative and concise, dramatically simplifying test code compared to manual object traversal.
Common Use Cases and Workflows
API response validation is the primary use case. After calling an endpoint, use JSONPath to extract values for assertion: verify that $.status is "success", confirm that $.data.users has the expected number of elements, check that $..price contains no negative values. This is cleaner and more maintainable than navigating response objects manually, especially when response structures change and you only need to update path expressions.
Data transformation pipelines benefit from JSONPath for extraction before transformation. You have a large API response but only need specific fields—use JSONPath to extract those fields into a new structure. $.results[*].{name: name, email: contact.email, city: address.city} (in implementations supporting projection) creates simplified objects. Even without projection syntax, extracting individual field arrays is useful: get names with one query, emails with another, then combine programmatically.
Configuration validation uses JSONPath to verify expected structure: confirm that $.database.connections[*].host returns values for all database connections, verify that $.features.beta_enabled exists and is boolean, check that $.api.endpoints[*].rate_limit is defined for every endpoint. This makes configuration validation testable and automated, catching missing or malformed configuration early.
Dynamic data extraction in user interfaces can use JSONPath for flexible data binding. If users can customize which fields they want to see from an API response, store their choices as JSONPath expressions. Evaluate those paths against the response and display the results. This is more flexible than hardcoded object navigation and enables user-configurable dashboards and reports without code changes.
Frequently Asked Questions
What is JSONPath and why would I use it?
JSONPath is a query language for JSON, similar to XPath for XML. It allows you to extract specific data from complex, nested JSON structures using path expressions instead of writing manual traversal code. For example, $.store.book[*].author extracts all book authors from a nested structure. It's essential for API testing, data extraction from large responses, and building flexible data processing pipelines without hardcoded object navigation.
What does the $ symbol mean in JSONPath?
The dollar sign ($) represents the root element of the JSON document. All JSONPath expressions start with $ to indicate you're querying from the top level. For example, $.users queries the 'users' property at the root level, $.users[0] gets the first user, and $.users[*].name gets all user names. The $ is analogous to the root directory / in filesystem paths.
How do I query arrays in JSONPath?
Arrays use square bracket notation. $.items[0] gets the first item (zero-indexed), $.items[2] gets the third item, $.items[-1] gets the last item. The wildcard $.items[*] gets all items in the array. You can use slices like $.items[0:3] for the first three items, or $.items[1:5:2] for items at indices 1, 3 (start:end:step). Array indexing is crucial for extracting specific elements from API responses.
What is the recursive descent operator (..) in JSONPath?
The recursive descent operator (..) searches for a property at any depth in the JSON structure. For example, $..price finds all properties named 'price' anywhere in the document, regardless of nesting level. This is extremely powerful for finding data when you know the property name but not its exact location. $..book[*].author finds all book authors no matter how deeply nested the book objects are.
Can JSONPath filter arrays based on conditions?
Yes! Filter expressions use the syntax [?(@.property operator value)]. For example, $.users[?(@.age > 30)] returns users older than 30, $.products[?(@.price < 100)] returns products under $100. The @ symbol represents the current item being evaluated. You can use operators like ==, !=, <, >, <=, >=. Filters are essential for extracting subsets of data matching specific criteria without writing custom code.
What's the difference between $.store.book and $['store']['book']?
Both notations access the same data—the 'book' property inside 'store'. Dot notation ($.store.book) is cleaner for simple property names. Bracket notation ($['store']['book']) is required when property names contain special characters, spaces, or start with numbers. For example, $['first-name'] or $['2023-data'] must use brackets. Bracket notation also allows dynamic property access with variables in programmatic JSONPath usage.
How do I get all values of a specific property across an array?
Use the wildcard with dot notation: $.users[*].email gets all email addresses from an array of user objects. This is much more concise than looping through the array manually. You can chain this: $.departments[*].employees[*].name gets all employee names across all departments. This projection capability is one of JSONPath's most powerful features for data extraction.
Can JSONPath return multiple results?
Yes! Most JSONPath expressions return arrays of matching results. $..[?(@.status == 'active')] might return multiple objects with that status. $..price returns all price values found anywhere in the document. Even expressions that logically match one item return an array with one element for consistency. If no matches are found, you get an empty array. This predictable array output makes result processing straightforward.
What are common JSONPath use cases in API development?
JSONPath excels in API testing and data extraction. Test that specific fields exist in responses: $.user.id. Extract all error messages: $..errors[*].message. Validate pagination: $.meta.total_pages. Filter test data: $.users[?(@.role == 'admin')]. Transform API responses by extracting only needed fields. Build dynamic queries based on user input. Verify nested data structures in integration tests. JSONPath makes complex API response validation simple and readable.
Is my JSON data secure when using the JSONPath tester?
Absolutely secure. All JSONPath evaluation happens entirely in your browser using client-side JavaScript. Your JSON data—whether it's API responses with sensitive information, customer data, or proprietary datasets—never leaves your computer, is never uploaded to any server, and is never logged or stored. The tool is completely private and safe for testing with production data.
JSONPath Resources and Further Learning
For the original JSONPath specification and comprehensive documentation, visit Stefan Gössner's JSONPath article, which introduced the concept. For JSON fundamentals, see JSON.org. For JavaScript implementation details, consult the MDN JSON documentation.
Complete Your JSON Workflow
Before using JSONPath, ensure your JSON is valid with our JSON Validator. Explore complex JSON structures visually with our JSON Viewer to understand the data before crafting queries. After extracting data with JSONPath, you might need to convert formats—use our JSON to CSV Converter for spreadsheet analysis, or our CSV to JSON Converter for preparing test data to query.