JSONPath workflow

Find the right JSONPath expression before shipping it

A JSONPath expression that looks right can still match the wrong nodes. Test it against real data first.

01

Build the expression incrementally

Start broad, then narrow the path until only the intended nodes match.

1

Paste the target JSON

Use a payload with the same shape as production data.

2

Write a starting path

Begin from the root and add one segment at a time.

3

Check the matches

Confirm the count and content of every matched node.

4

Narrow with filters

Add conditions until only the intended values remain.

02

Paths that cover most queries

  • $.users selects the users array
  • $.users[0].name selects the first user name
  • $..email finds every email at any depth
  • $.users[?(@.active == true)] filters active users
03

Test before you ship

  1. 1

    Open the JSONPath tester and paste the document.

  2. 2

    Enter the expression and check the highlighted matches.

  3. 3

    Compare the match count with your expectation.

  4. 4

    Use the same expression in your code, knowing it was tested on real data.

04

Why paths match too much or too little

  • A wildcard matches more nodes than expected
  • Array indexes shift when data order changes
  • A filter condition targets the wrong property
  • Deeply nested arrays are easy to miscount
05

Write durable expressions

  • Prefer named properties over positional indexes
  • Test against more than one payload shape
  • Keep filters explicit rather than overly broad
  • Document the expression next to where it is used
06

Frequently asked questions

What is the difference between . and .. ?

A dot selects a direct child; the double dot searches recursively at any depth.

How do filters work?

Filters use [?(@.field == value)] and support comparisons, logical operators, and existence checks.

Can JSONPath select multiple matches?

Yes. Expressions such as $..email return every matching value as an array.

Is my JSON uploaded?

No. The tester runs locally in your browser.

07

Queries run against local data

The JSONPath tester evaluates expressions in the browser. Remove sensitive values from shared test payloads.

Open JSONPath Tester