Paste a JSON document and get a JSONPath expression for every field it contains. Array positions can be emitted either as concrete indices or as a [*] wildcard, and keys that need quoting are written in bracket form automatically. Everything runs in your browser.

Generate JSONPath expressions

Opens the tool with the JSONPath output format already selected.

Open the generator

A worked example

Given this order payload:

{
  "user": {
    "name": "Ada Lovelace",
    "address": { "city": "London", "country": { "code": "GB" } },
    "roles": ["admin", "engineer"]
  },
  "orders": [
    { "orderId": "ord_1001", "total": 249.99 },
    { "orderId": "ord_1002", "total": 15.50, "giftMessage": "Happy birthday" }
  ]
}

With Collapse array indices enabled, you get wildcard expressions - one per distinct field:

$.user
$.user.name
$.user.address
$.user.address.city
$.user.address.country
$.user.address.country.code
$.user.roles
$.orders
$.orders[*].orderId
$.orders[*].total
$.orders[*].giftMessage

With collapsing turned off, each array element is addressed by its literal index instead:

$.user
$.user.name
$.user.address
$.user.address.city
$.user.address.country
$.user.address.country.code
$.user.roles
$.orders
$.orders[0].orderId
$.orders[0].total
$.orders[1].orderId
$.orders[1].total
$.orders[1].giftMessage

The wildcard form is what you usually want when writing a query. The indexed form is more useful when you are inspecting one specific record and need the exact address of a value.

Dot notation vs JSONPath

These are related but not the same thing, and the distinction matters:

  • Dot notation (orders[0].total) describes where a key sits in the document. It is a description of structure.
  • JSONPath ($.orders[*].total) is a query language. The leading $ marks the document root, and wildcards let one expression match many values at once.

JSONPath is supported by libraries in most languages - jsonpath and jsonpath-plus for JavaScript, jsonpath-ng for Python - and appears in tools such as Kubernetes kubectl -o jsonpath, Azure CLI queries, and various API gateways.

Keys that need bracket notation

A key is only written after a dot when it is a bare identifier. Anything else - a key containing a dot, a space, or a hyphen, or one starting with a digit - is emitted in bracket-with-quotes form so the expression stays valid:

$.user.name              a bare identifier
$['user.name']           a key containing a literal dot
$['first name']          a key containing a space
$['2fa-enabled']         starts with a digit, contains a hyphen

This matters because $.user.name and $['user.name'] address completely different things. The first walks two levels down; the second reads a single key whose name happens to contain a dot.

How to use it

  1. Copy a JSON response from your API client or browser DevTools
  2. Open the generator - the JSONPath format is preselected
  3. Paste into the left box, or drag a .json file onto it
  4. Toggle Collapse array indices depending on whether you want [*] or literal indices
  5. Click Extract Keys, then copy or download the result

Other output formats

Further reading