logo
GeekFormat

JSONPath Query

Online JSONPath query tool supporting $.property access, [n] array index, [*] wildcard, [start:end] array slicing, and ?() conditional filter expressions. Real-time query with 400ms debounce after input, supporting both formatted JSON view and aligned table view toggle. 8 built-in common path examples, auto-fix for JSON syntax errors, support for uploading JSON files, downloading query results, keyboard shortcuts, and automatic local history saving. Resizable side panels, font size switching, and all parsing and queries executed entirely locally in the browser with zero data upload. Suitable for QA testing API assertions, backend debug log field extraction, and frontend API response validation.

Related

Use Cases

  • QA test engineers interactively verify that JSONPath assertion expressions correctly extract target fields before writing API automation tests
  • Backend developers quickly locate deep field paths when debugging complex nested API responses without manually expanding layer by layer
  • Frontend developers integrating third-party APIs quickly validate returned JSON structure, confirming field paths before writing code
  • DevOps/backend engineers extract specific field values from JSON in ELK, Jaeger logs when troubleshooting
  • Perform conditional filtering on JSON API response data before data analysis, filtering out matching records first for subsequent processing
  • Debug expressions locally before configuring JSON extractors in Postman, JMeter, RestAssured and other tools to avoid repeatedly calling APIs
  • Process batch JSON data by quickly extracting required field subsets to generate new data structures
  • Learn JSONPath syntax with real-time feedback to quickly verify various syntax approaches and deepen understanding
  • Verify data extraction paths from JSON API responses during crawler development and debugging
  • Validate example JSON paths with the tool before writing them into API documentation
  • Mobile developers debug APIs by temporarily opening the tool on a phone to quickly verify field extraction without needing a computer
  • Check whether JSONPath expressions written by colleagues return expected values during Code Review

Features

  • Practical syntax support: $.property access, [n] array index (including [-1] for last item), [*] wildcard, [start:end] array slicing, ?() conditional filtering (supports ==/!=/>/</>=/<= comparisons)
  • Live query: 400ms debounce auto-execution after JSON or path input, no button click needed, results update instantly
  • JSON/table dual view: Query results support beautified JSON view and aligned table view toggle; object array results automatically align by columns for quick browsing
  • Built-in examples: Dropdown menu provides 8 common path examples (root object, all books, first/last item, slice, price extraction, conditional filtering, etc.), click to fill
  • Syntax help popup: One-click help panel showing 6 core syntax quick references and keyboard shortcut guide, with auto-adapted Mac/Windows shortcut display
  • Smart error fixing: Automatically detects fixable JSON format issues, one-click repair for common JSON syntax errors (missing commas, quotes, trailing commas, etc.)
  • One-click formatting: Built-in JSON formatter, Shift+Cmd/Ctrl+F quickly beautifies input JSON with clean indentation for easy hierarchy reading
  • File upload and download: Supports uploading .json/.txt files to read content directly; query results can be downloaded as query-result.json with one click
  • Keyboard shortcuts: Shift+Cmd/Ctrl key combinations for quick actions (Enter to query, F to format, O to upload, D to download, K to clear), boosting efficiency
  • Local history: Automatically saves up to 200 recent entries to browser localStorage, restores previous content on next visit without re-pasting
  • Resizable panels: On desktop, drag the middle divider to adjust left-right panel width ratio, flexibly allocating space based on JSON structure
  • Font size switching: Supports 14px/16px code font size toggle, protecting eyes during extended debugging sessions
  • CodeMirror editor: Built on CodeMirror with syntax highlighting, line numbers, and bracket matching for a professional editing experience
  • Browser-local processing: All JSON parsing, path matching, and conditional filtering execute in local JavaScript; no data uploaded to servers; safe for sensitive API data and logs

How to Use

  1. Click the "Examples" button in the toolbar to load sample JSON for a quick start, or paste/upload your own JSON data into the left editor
  2. Enter a JSONPath expression in the query box at the top (click the "Examples" button on the right to select common paths); starting with $ or directly writing the property path both work
  3. Auto-query runs after 400ms and results appear immediately on the right; toggle between "JSON View" for formatted structure or "Table View" for aligned lists
  4. After verifying the expression is correct, click copy or download to save results; you can also copy the JSONPath expression for use in Postman/JMeter and other tools

FAQ

What JSONPath syntax is supported?

The following practical syntax is supported: ①$.property or ['property'] for object property access; ②[n] for array element access by index (n starts from 0, [-1] indicates the last item); ③[*] or .* wildcard, matching all array elements or all object property values; ④[start:end] array slicing to extract elements in a specified range; ⑤?(@.field op value) conditional filtering, supporting six comparison operators ==/!=/>/</>=/<= for both string and numeric comparisons.

How do I extract array elements that meet a condition?

Use the ?() conditional filter expression. For example, $.store.book[?(@.price < 80)] filters books priced below 80, and $.store.book[?(@.category == 'programming')] filters books in the programming category. Note that property names must be prefixed with @. to refer to the current element, and string values should be wrapped in single or double quotes.

How do I get the first/last/first N elements of an array?

[0] gets the first element, [-1] gets the last element, [0:2] gets the first two elements at indices 0 and 1 (slicing is left-closed right-open, not including the end index). For example, $.store.book[0:3] gets the first three books.

What's the difference between table view and JSON view?

JSON view displays standard formatted indented JSON results, preserving the complete nested structure, suitable for copying and viewing full data; table view automatically aligns object array results by property columns, similar to an Excel spreadsheet, making it more intuitive when browsing multiple records and allowing quick scanning across rows to compare field value differences. Simple type results are also displayed as aligned key-value pairs.

What should I do when a JSON parse error is shown?

If the input JSON has syntax errors (missing commas, mismatched quotes, extra trailing commas, single quotes, etc.), the error area shows a red highlight and a "Fix Errors" button appears. Click it to automatically attempt repairing common JSON issues. You can also try formatting with Shift+Cmd/Ctrl+F first; if formatting reports an error, the JSON genuinely has problems that need fixing before querying.

No results are displayed after querying?

Please check: ①Is the JSON valid (click the format button to verify); ②Is the JSONPath path spelled correctly — property names are case-sensitive; ③Does the path exist (accessing a non-existent property will cause an error); ④Is the filter expression syntax correct, with properly paired brackets and quotes.

How do I use the built-in examples?

Click the "Examples" button (down arrow) on the right side of the query box; the dropdown menu lists 8 common path examples. Clicking any example automatically fills in the path expression. It's recommended to first click "Examples" to load the sample JSON data (bookstore data) to experience the effect with example paths.

What keyboard shortcuts are available?

All use Shift+Cmd(Mac)/Shift+Ctrl(Windows) combinations: Shift+Enter executes query, Shift+F formats JSON, Shift+O uploads file, Shift+D downloads results, Shift+K clears all content. The help button (? icon) shows the full shortcut list anytime.

What comparison operators does conditional filtering support?

Six comparison operators are supported: == (equals), != (not equals), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal). Numeric comparisons compare by numeric magnitude; string comparisons compare lexicographically; string values must be wrapped in single or double quotes.

Does the path need to start with $?

It's not strictly required. The tool automatically prepends $. at the beginning; typing store.book[0] directly also works, as the system normalizes it to $.store.book[0] for execution. However, the standard JSONPath specification recommends starting with $ to denote the root node.

Why is my previously entered content still there when I open it again?

The tool automatically saves recently entered JSON to browser localStorage (up to 200 history entries). It restores the previous content on next visit, so you don't need to re-paste API response results every time. The clear button (Shift+K) clears current content.

Can I upload JSON files?

Yes. Click the "Upload" button in the toolbar or press Shift+O, select a local .json or .txt file, and the file content will be automatically read into the input box. Query results can also be saved locally as query-result.json by clicking the "Download" button or pressing Shift+D.

Is it suitable for Postman/JMeter API assertions?

Very much so. During API debugging, paste the API response JSON into the tool, interactively adjust the JSONPath expression until the query results match expectations, then copy the validated expression into Postman test scripts, JMeter JSON Extractor, or automation test frameworks. This can significantly reduce online debugging time.

Will my API data be uploaded to a server?

No. All JSON parsing, JSONPath path matching, conditional filtering, and table formatting are completed locally in your browser via JavaScript. The JSON content you input is never sent over the network to any server. After closing the page, only local localStorage retains data (which can be cleared). Sensitive business data and pre-release API data can be used safely.

Can the wildcard [*] be used on objects?

Yes. [*] used on an array returns all array elements; used on an object (e.g., $.store.*) returns an array of all object property values. When combined with property access such as $.store.book[*].author, it can extract the author field from all array elements, forming a list of authors.

About JSONPath and Data Extraction

JSONPath is a path expression language for extracting specified data from JSON documents, similar to what XPath does for XML. In API development and testing, JSON responses often have deep hierarchies and heavy nesting. Manually expanding layers to find fields is inefficient and error-prone. Using JSONPath, you can precisely locate and extract target data with a single line expression, making it an essential tool for API debugging, automated testing, and data extraction scenarios.

JSONPath's core design idea is to describe data positions using path notations: $ denotes the root node (the entire JSON object), dot . or square brackets [] access child properties, [n] accesses array elements by index, [*] matches all elements, [start:end] slices array segments, and ?() filters array elements by condition. This syntax is concise yet expressive, covering the vast majority of data extraction needs.

Conditional filtering is one of JSONPath's most practical features. It expresses selection logic in the form ?(@.field operator value), such as ?(@.price < 100) filtering array items where the price field is less than 100, or ?(@.status == 'active') filtering records with active status. @ represents the current array element being iterated, and @.field accesses a specific field of the current element, making conditional filtering very intuitive.

Why use a dedicated JSONPath tool instead of debugging directly in code? When writing API automation assertions or data extraction code, if the JSONPath is wrong, you may need to repeatedly call the API, print logs, modify code and rerun — which is very inefficient. Interactive debugging in an online tool lets you see results in seconds, adjusting expressions with instant feedback. Once validated, you copy the correct expression into code, saving significant debugging time.

Table view is a practical feature that distinguishes this tool from many similar tools: when query results are an array of objects (the most common API response list format), it automatically extracts all object keys as table headers and displays each row aligned, providing an Excel-like browsing experience. This is much more intuitive than hunting for field values line by line in indented JSON, allowing quick scanning to compare field differences across multiple records.

Auto-fixing JSON errors is another feature designed for real development scenarios: JSON copied from logs, documentation, or chat windows often has various small issues — single quotes used instead of double quotes, missing commas, extra trailing commas on the last item, unquoted property names, etc. Manual fixing is tedious, but the tool's auto-repair feature can handle most common JSON format issues in one click, without needing to find errors character by character.

Local history is a small detail optimized for frequent use: developers often need to repeatedly debug the same API, and re-pasting JSON every time they open the tool is cumbersome. The tool automatically saves recent inputs to browser local storage and restores previous content on next visit, with 200 history entries sufficient for daily work. All data stays only in your own browser and is never uploaded.

Note that this tool supports a practical core subset of JSONPath syntax (property access, indexing, wildcard, slicing, conditional filtering), covering over 90% of daily development scenarios. Advanced syntax such as recursive descent (..), script expressions, and multi-condition combinations are not currently supported. If your scenario requires these advanced features, you may need to use a more complete implementation library. For the vast majority of API debugging and field extraction needs, the current syntax set is fully sufficient and more lightweight and fast.

术语表

JSONPath
A path expression language for extracting specified portions from JSON data, similar to XPath for XML, describing target data location through path notation.
Root node ($)
The starting point of a JSONPath expression, representing the root object or root array of the entire JSON document. Paths can start with $; the tool also supports omitting $ and writing the path directly.
Current node (@)
Used in filter expressions to represent the current array element being iterated; @.field accesses a specified field of the current element.
Property access (.property or ['property'])
Two ways to access an object's specified property: dot notation ($.store.book) is concise, while bracket-quote notation ($['store']['book']) suits property names containing special characters.
Array index ([n])
Access array elements by position; indices start at 0, [0] is the first element, [-1] is the last element.
Wildcard ([*] or .*)
Matches all children at the current position: used on an array returns all elements, used on an object returns all property values.
Array slicing ([start:end])
Extracts a segment of an array using a left-closed right-open interval (includes start, excludes end); omitting start means from the beginning, omitting end means to the end.
Conditional filtering (?())
Filters array elements by condition, containing comparison expressions inside; supports six comparisons ==/!=/>/</>=/<=; string values must be wrapped in quotes.
Postman assertions
Tests scripts in the Postman API testing tool that use JSONPath to extract API response fields and perform assertion validation, a common approach for API automated testing.
Debounce
An optimization technique that delays query execution until input stops (400ms in this tool), avoiding re-querying on every keystroke to improve input smoothness.
CodeMirror
A browser-based code editor component providing syntax highlighting, line numbers, bracket matching and other professional code editing features; used by this tool as the JSON editing area.
Local processing
All JSON parsing and query logic executes via JavaScript within the user's browser; data is not uploaded to servers, making it both fast and secure for sensitive data handling.

JSONPath Core Syntax Quick Reference

All syntax supported by this tool:

SyntaxDescriptionExample result (sample bookstore JSON)
$Root object, returns the entire JSONComplete store object
$.store.book[0]Access the first element of the book array (indices start from 0)The book 'JavaScript: The Definitive Guide'
$.store.book[-1]Access the last element of the arrayThe book 'The Elements of User Experience'
$.store.book[*]Wildcard, returns all array elementsArray of all 3 books
$.store.book[0:2]Array slicing, takes indices 0 to 1 (left-closed right-open)First 2 books
$.store.book[*].authorExtract the author field from all array elements["Zhang San","Li Si","Wang Wu"]
$.store.book[?(@.price < 80)]Conditional filtering, selects books with price<80Python and UX books (prices 79 and 59)
$.store.bicycle.colorDot notation access to nested object property"red"

Conditional Filter Comparison Operators

Operators supported in ?() filter expressions:

OperatorMeaningExample
==Equals (supports numbers and strings)?(@.category == 'programming')
!=Not equals?(@.status != 'deleted')
>Greater than (numeric comparison)?(@.price > 100)
<Less than?(@.price < 50)
>=Greater than or equal?(@.age >= 18)
<=Less than or equal?(@.count <= 100)

Keyboard Shortcuts List

All shortcuts use Shift + Cmd(Mac)/Ctrl(Windows) key combinations:

ActionMac ShortcutWindows Shortcut
Execute query⇧ + ⌘ + EnterShift + Ctrl + Enter
Format JSON⇧ + ⌘ + FShift + Ctrl + F
Upload file⇧ + ⌘ + OShift + Ctrl + O
Download results⇧ + ⌘ + DShift + Ctrl + D
Clear content⇧ + ⌘ + KShift + Ctrl + K

Privacy & Security

All JSON parsing, path matching, conditional filtering, and table formatting in this JSONPath query tool runs entirely locally in your browser via JavaScript. The JSON data you input, the paths you query, and the returned results are never uploaded to any server, nor recorded, cached, or stored in the cloud. Input history is only saved in your browser's local localStorage (up to 200 entries), which you can delete via the clear button or by clearing browser data. Content containing sensitive business fields, pre-release API data, and production logs can be used safely with zero data leakage risk.

Authoritative References

Troubleshooting

Error: 'Path does not exist or value is null/undefined'

This means the JSONPath path cannot find a corresponding value in the current JSON. Check: ①Is the property name spelling and casing correct (JSON is case-sensitive); ②Is the nesting level correct and do intermediate layers exist; ③Is the array index out of bounds; ④Click format first to confirm the JSON structure matches your expectations.

Error: 'Attempted to use index/slice/filter on a non-array object'

This means you used [] index, [start:end] slice, or ?() filter on a non-array value. These operations can only be used on arrays. Check whether the position in the path actually corresponds to an array or a single object; you can first use the $ wildcard or root path to confirm the actual structure.

Conditional filtering does not return expected results

Check: ①Is there a dot after @ (must write @.field, the dot cannot be omitted); ②Are string values wrapped in single/double quotes (?(@.name == zhangsan) is wrong; write ?(@.name == 'zhangsan')); ③Do not quote numeric values or they will be compared as strings; ④Avoid extra spaces on either side of comparison operators.

Error: 'Bracket mismatch'

This means square brackets [] or filter parentheses () in the JSONPath expression are not properly paired. Check if a closing ] or ) is missing, especially with nested square brackets — ensure every [ has a corresponding ].