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.
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
- 1Format or validate the JSON first if the structure is hard to read or may still be invalid.
- 2Write a JSONPath expression that targets the smallest useful part of the payload.
- 3Run it in a JSONPath tester and inspect the returned values plus their absolute paths.
- 4Tighten or loosen the expression until the matches are exactly what you expect.
Common JSONPath patterns
| Pattern | Meaning | Example |
|---|---|---|
| $.name | Select a top-level property | Get the root name field |
| $.items[0] | Select the first array item | Get the first item in items |
| $.items[*].id | Select a property from every array item | Get all ids inside items |
| $.items[?(@.enabled==true)] | Filter array items by a condition | Return 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 expressionQuick 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.
Open JSONPath Tester
Run JSONPath expressions against a real payload and inspect the matched values with their paths.
Open JSON Formatter
Format the JSON first so nested arrays and objects are easier to inspect before you write the query.
How to Format JSON
Learn how to format JSON safely, pick the right indentation, and spot invalid input before you copy output into code or docs.
How to Validate JSON
Use a JSON validator to check syntax, read parse errors, and locate the exact line and column causing invalid JSON.