How do you write a JSONPath query that returns exactly the values you want?

Start with readable JSON, write the smallest expression that reaches the value you want, then test and refine the path until the matches are correct.

3 min readJSONPath Tester / JSON Formatter / JSON Validator
TL;DRJSONPath is a query language for selecting values from structured JSON, especially when the data is nested inside arrays and objects.

What JSONPath helps with

JSONPath is useful when you need to extract specific values from large or nested JSON payloads instead of scanning the whole object manually.

It is common in API debugging, mapping workflows, assertions, and data extraction steps where one field matters more than the rest of the payload.

Fast workflow

  1. 1Format or validate the JSON first if the structure is hard to read or may still be invalid.
  2. 2Write a JSONPath expression that targets the smallest useful part of the payload.
  3. 3Run it in a JSONPath tester and inspect the returned values plus their absolute paths.
  4. 4Tighten or loosen the expression until the matches are exactly what you expect.

Common JSONPath patterns

PatternMeaningExample
$.nameSelect a top-level propertyGet the root name field
$.items[0]Select the first array itemGet the first item in items
$.items[*].idSelect a property from every array itemGet all ids inside items
$.items[?(@.enabled==true)]Filter array items by a conditionReturn only enabled items

Example payload

Use a small, readable payload like this when you are building the first version of a query.

A good first query

This expression returns the names of the environments where enabled is true.

Try It

Test this JSONPath expression

Open the JSONPath tester when you want to run the expression against a real payload and inspect the match list immediately.

Test this JSONPath expression

Quick answers

What to do next

Start with the right tool now, then move back to the hub or sideways into the adjacent guides if the first answer was not the whole fix.