JSONPath Examples: Extract Values from JSON with a Path Finder

5/28/20264 min readBy RM
jsonjsonpathapidebuggingjavascriptdata

You get a 200 KB API response and only need one field, or every id in a list. Clicking through collapsed JSON in DevTools gets old fast. JSONPath lets you start at $ (the root) and walk down to the value you want.

Use the JSON Path Finder to paste JSON, enter a path, and see the result immediately. Format messy payloads first with the JSON Formatter if the structure is hard to read.

JSONPath syntax in 30 seconds

PieceMeaningExample
$Root of the document$
.keyChild property$.user.name
[n]Array index (0-based)$.items[0]
[*]All items at this level$.items[*]
ChainingCombine steps$.store.book[0].title

Keys are case-sensitive. Use bracket notation when a key contains spaces or special characters: $["order-id"].

Sample JSON (API-style)

Use this document in the path finder while you try the examples below:

{
  "status": "ok",
  "user": {
    "id": 42,
    "profile": {
      "email": "dev@example.com",
      "displayName": "Alex"
    }
  },
  "orders": [
    { "id": "A-100", "total": 19.99, "paid": true },
    { "id": "A-101", "total": 4.50, "paid": false }
  ],
  "meta": {
    "requestId": "req_8f2a",
    "version": 2
  }
}

Examples to copy and paste

Paste each path into the JSON Path Finder with the sample JSON above.

Root document

$

Nested email

$.user.profile.email

Result: "dev@example.com"

First order ID

$.orders[0].id

Result: "A-100"

Second order total

$.orders[1].total

Result: 4.5

Request metadata

$.meta.requestId

Result: "req_8f2a"

All orders (array wildcard)

$.orders[*]

Result: the full orders array. Useful when you want every object before filtering in code.

Status flag

$.status

Result: "ok"

Typical workflows

Debug an API response

  1. Copy JSON from Network tab, Postman, or curl.
  2. Paste into JSON Formatter if it is minified.
  3. Guess a path ($.data.items[0].sku) and test it in the path finder.
  4. If the path fails, walk up one level ($.data.items) and inspect structure before trying again.

Compare two payloads

After extracting paths from two responses, use Compare and Diff or JSON Merge when you need to see what changed between versions.

Validate before production

If the API must match a contract, pair path checks with the JSON Schema Validator and JSON Validator so structure and types are both covered.

Common mistakes

  • Wrong root. Paths must start with $. user.email without $ will not behave as JSONPath.
  • Off-by-one indices. JSON arrays are zero-based; the first item is [0], not [1].
  • Dots in keys. $.user-name is wrong for key user-name; use $["user-name"].
  • Assuming filters. Full JSONPath specs include filters like $[?(@.price < 10)]. Many online tools focus on $, ., [], and *. Test advanced syntax before you rely on it in production.
  • Minified JSON typos. A missing comma breaks parsing entirely. Validate JSON first.

JSONPath vs other approaches

ApproachBest for
JSONPathQuick extraction, logs, ad-hoc API debugging
jq (CLI)Scripting and pipelines in the terminal
JavaScript obj.a.bCode when the shape is fixed and typed
JSON SchemaEnforcing allowed structure, not one-off queries

For one field from a large response, JSONPath plus an online finder is usually the fastest loop.

When to use something else

  • Transform or reshape entire documents: use code, jq, or ETL tools, not a single path.
  • Highly filtered queries (e.g. all orders where paid is false): filter in code or use an engine that supports JSONPath filters.
  • Non-JSON bodies: XML, CSV, or plain text need different tools.

FAQ

What is JSONPath?

A query language for JSON. Expressions start at $ and navigate objects and arrays to return matching values.

How do I find a nested value in JSON?

Build a path from the root: $.parent.child.field. Test it in the JSON Path Finder.

What does $.items[*] mean?

Select all elements in the items array at that step of the path.

What does $.users[0].id mean?

The id field of the first object in the users array.

Is JSONPath the same as JavaScript dot notation?

Similar for simple paths, but JSONPath always uses $ as root and supports [*] wildcards and bracket keys in a standard way.

Why does my path return “not found”?

Check spelling, casing, array bounds, and that the JSON is valid. Format the payload and walk the tree manually one level at a time.

Related tools