Small JSON is easy to read. Large JSON is different. A real API response can contain nested objects, arrays, metadata, and fields you do not care about.

JSONPath helps ask focused questions like:

“Show me every email address in this response.”

or:

“Find the order whose status is paid.”

The JSON Path Explorer lets you paste JSON, try a JSONPath expression, and see the matching values.

The simple idea

JSONPath is like a path through JSON.

Given this JSON:

{
  "user": {
    "name": "Ana",
    "email": "ana@example.com"
  }
}

This JSONPath:

$.user.email

returns:

ana@example.com

The $ means “start at the root”. Then .user.email walks down into the object.

Step 1: start at the root

Every JSONPath usually starts with:

$

That means the whole document.

If you run only $, you are selecting everything.

Step 2: select a normal object field

For object fields, use dots:

$.user.name

Given:

{
  "user": {
    "name": "Ana"
  }
}

Result:

Ana

This is the easiest case.

Step 3: select an array item by index

Arrays use numbers starting from zero.

Given:

{
  "users": [
    { "name": "Ana" },
    { "name": "Budi" }
  ]
}

This selects the first user:

$.users[0]

This selects the second user’s name:

$.users[1].name

Result:

Budi

Step 4: select every item in an array

Use * to mean every item:

$.users[*].name

Given:

{
  "users": [
    { "name": "Ana" },
    { "name": "Budi" }
  ]
}

Result:

Ana
Budi

This is one of the most useful JSONPath patterns.

Step 5: find a field anywhere

Sometimes you do not know where a field is nested. Recursive search can help:

$..email

Plain meaning:

Find every field named email anywhere in the document.

This is useful for exploring an unfamiliar response.

Be careful with very large JSON documents. Recursive searches can return many matches.

Step 6: filter array items

Filters let you select objects that match a condition.

Given:

{
  "orders": [
    { "id": 1, "status": "paid" },
    { "id": 2, "status": "pending" }
  ]
}

This selects paid orders:

$.orders[?(@.status == "paid")]

Plain meaning:

Inside orders, keep items where the item’s status is paid.

The @ means “the current item being checked”.

To get only the id:

$.orders[?(@.status == "paid")].id

Result:

1

Step 7: use the explorer instead of guessing

Open JSON Path Explorer and paste your JSON.

Then try simple expressions first:

$
$.users
$.users[*]
$.users[*].email

Build the path one step at a time. Do not start with a complicated filter.

The explorer is useful because it shows both the matched value and its path. That helps you learn the structure of the JSON.

Step 8: click through the tree

When the JSON shape is unfamiliar, I start by expanding the tree view.

I look for:

  • arrays of records;
  • repeated field names;
  • ids;
  • status fields;
  • timestamps;
  • nested data objects;
  • pagination metadata.

Then I write the JSONPath after I understand where the value lives.

Common JSONPath patterns

Select all ids:

$..id

Select names from a users array:

$.users[*].name

Select the first item:

$.items[0]

Select paid orders:

$.orders[?(@.status == "paid")]

Select email fields anywhere:

$..email

My JSONPath checklist

When writing a JSONPath expression, I check:

  1. Does the JSON start with an object or an array?
  2. What is the root path?
  3. Am I selecting one item by index or all items with *?
  4. Do I know the exact field location, or should I explore with $..field?
  5. If filtering, what does one array item look like?
  6. Can I build the expression one step at a time?

JSONPath is not about memorising every feature. It is about turning a large response into a small answer.

Comments

Comments are welcome — please read the comment policy first. Powered by giscus and GitHub Discussions.