toolgarden.xyz
中文

JSONPath Query

Free online JSONPath query tool to extract nested fields from JSON / JSONC / JSON5 using JSONPath expressions

Input JSON / JSONC / JSON5

JSONPath Expression

Query Result

[
  "活着",
  "围城",
  "白夜行"
]

About this tool

JSONPath selects nodes from nested JSON with an expression combining path navigation and query conditions. `$` names the root, dot or bracket syntax accesses properties, `*` selects siblings, and recursive descent or filters locate matches inside unknown depths and arrays.

Queries run through jsonpath-plus and the result is always emitted as an array, even for one match. This distinguishes no match from one match and lets the same expression handle single and repeated data.

How to use it

  1. Enter valid JSON

    Confirm the document parses and identify the object or array that contains the values of interest.

  2. Write a JSONPath expression

    Start at `$`, narrow with properties and indexes, then add wildcards or filters only where needed.

  3. Review the result set

    Check match count and value types. An empty array means the expression ran but selected nothing.

Input and output example

Three common expressions against one document. Note that the result is always an array.

Data and expressions
// data
{ "books": [
    { "title": "A", "price": 8 },
    { "title": "B", "price": 20 } ] }

$.books[*].title
$.books[?(@.price < 10)].title
Query results
["A", "B"]

["A"]

Supported range and limits

Expression syntax
JSONPath, rooted at $, descending with dots or brackets
Common forms
$.store.book[0].title for one value, $..author to search recursively, $.book[*].price for all
Filters
?() conditions are supported, as in $.book[?(@.price < 10)]
Return shape
Always an array of matches; no match yields an empty array rather than an error
vs browsing the structure
The formatter is for surveying a document; JSONPath is for pulling one part out of a very large one
Dialect differences
JSONPath has no single authoritative spec, so implementations differ slightly on filters and recursion

When you would use it

  • Extracting fields from an API response

    Collect every product ID, error message, or email from a deeply nested paginated response.

  • Checking a data distribution

    Use a filter to find array members with out-of-range prices, unexpected states, or missing target fields.

  • Pulling a subtree out of a very large response

    Clicking through a tree view of tens of megabytes is slow; one expression extracts the branch you need to inspect on its own.

What to know before you start

  • Property names containing dots, spaces, or hyphens need quoted bracket notation so they are not split into path segments.
  • Filter expressions can evaluate conditions. Do not embed untrusted expressions directly in production code.
  • JSONPath has several dialects, so retest complex expressions before moving them to another library.

Related concepts

root selector
The `$` at the beginning of an expression, representing the current JSON document root.
recursive descent
The `..` operator for finding a named property at any depth; useful but capable of selecting more than expected.

Frequently asked questions

What can JSONPath do?
A JSONPath expression (such as $.store.book[*].title) lets you extract specific fields or array elements from nested JSON.
Are wildcards and filters supported?
Yes. You can use wildcards, recursive descent and filter expressions to pick out the data you need from complex structures.
Does querying upload my data?
No. JSONPath queries run locally in your browser and data is never uploaded.
Why is the result always an array?
Because JSONPath means "select every matching node", and that count may be zero, one or many. Always returning an array distinguishes no match (empty) from one match (length 1), and lets the same expression handle single and repeated values.
How do I address a property with a dot or hyphen in its name?
Quoted bracket notation: `$['user-name']` or `$['a.b']`. Writing `$.user-name` is parsed as subtraction or as separate path segments and will not do what you want.