JSONPath Tester
Test JSONPath expressions against JSON data and see matching results instantly. Runs entirely in your browser.
Example expressions (loads with example data)
JSONPath Quick Reference
$Root element$.keyChild key$.*All children$.a.bNested path$.arr[0]Array index$.arr[-1]Last element$.arr[*]All elements$.arr[0,2]Index 0 and 2$.arr[0:3]Slice 0 to 3$.arr[?(@.x > 5)]Filter expression$..keyRecursive descent$.arr[*].keyKey from all itemsWhat is JSONPath?
JSONPath is a query language for JSON, analogous to XPath for XML. It lets you extract specific values or arrays of values from a JSON document using a path expression starting with $ (the root element). JSONPath was originally described by Stefan Goessner in 2007 and has since been standardized as RFC 9535 (2024).
JSONPath is built into many tools developers use daily: AWS Step Functions state machine definitions, Kubernetes jsonpath output formatting, Grafana alert conditions, Postman test scripts, Karate API testing, and JMESPath alternatives. This tool uses jsonpath-plus, an extended implementation that adds filter expressions, script expressions, and type selectors beyond the original spec.
JSONPath syntax reference
| Expression | Meaning | Example |
|---|---|---|
| $ | Root element | $ |
| . | Child operator (dot notation) | $.store.name |
| ['key'] | Child operator (bracket notation) | $['store']['name'] |
| ..* or $..* | Recursive descent — all descendants | $..price |
| [n] | Array index (zero-based) | $.books[0] |
| [-1] | Last element | $.books[-1] |
| [*] | All elements of array or object | $.books[*].title |
| [0,2] | Union — index 0 and index 2 | $.books[0,2] |
| [1:4] | Slice — index 1 up to (not including) 4 | $.books[1:4] |
| [::2] | Slice with step — every 2nd element | $.books[::2] |
| [?(@.price < 10)] | Filter — items where expression is true | $.books[?(@.price < 10)] |
| [?(@.author == 'Orwell')] | Filter by string equality | $.books[?(@.author == 'Orwell')] |
| [?(@.isbn)] | Filter — items that have this property | $.books[?(@.isbn)] |
| length(@) | Length of array or string | $.books[?(length(@.title) > 5)] |
JSONPath in popular tools
| Tool | Context | Example |
|---|---|---|
| AWS Step Functions | InputPath, OutputPath, ResultPath, Parameters | $.order.items[0].productId |
| Kubernetes kubectl | --jsonpath flag for output formatting | kubectl get pods -o jsonpath='{.items[*].metadata.name}' |
| Grafana | JSON API datasource field paths | $.data.metrics[*].value |
| Postman | Test assertions on response body | pm.response.json().users[0].email |
| Spring Boot | @JsonPath in MockMvc tests | $.content[0].id |
| Karate | JSONPath in match assertions | match response.users[*].role contains 'admin' |
| Prometheus alertmanager | JSON payload extraction rules | $.alerts[?(@.status=='firing')] |
Use JSONPath in code
JavaScript (jsonpath-plus)
import { JSONPath } from 'jsonpath-plus';
const result = JSONPath({ path: '$.store.books[*].title', json: data });JavaScript (jsonpath)
const jp = require('jsonpath');
const titles = jp.query(data, '$.store.books[*].title');Python (jsonpath-ng)
from jsonpath_ng import parse
expr = parse('$.store.books[*].title')
matches = [m.value for m in expr.find(data)]Go (gjson)
import "github.com/tidwall/gjson" result := gjson.Get(json, "store.books.#.title")
Java (Jayway JsonPath)
List<String> titles = JsonPath.read(json, "$.store.books[*].title");
PHP (FlowCommunications/jsonpath)
$jsonPath = new JSONPath($data);
$titles = $jsonPath->find('$.store.books[*].title')->data();JSONPath vs jq vs JMESPath
| Feature | JSONPath | jq | JMESPath |
|---|---|---|---|
| Syntax | $.store.books[*].title | .store.books[].title | store.books[*].title |
| Filter | ?(@.price < 10) | select(.price < 10) | [?price < `10`] |
| Recursion | $..* | .. | .price? | N/A |
| Transform/map | Limited | Full (map, reduce, etc.) | Moderate |
| Used in | AWS Step Functions, K8s | CLI, scripts | AWS CLI, CloudFormation |
| Standard | RFC 9535 (2024) | jq manual | RFC 9090 (2023) |
Frequently asked questions
What does $..key do (double dot)?▾
The .. operator is recursive descent — it searches the entire document tree for keys matching the given name, regardless of nesting depth. $..* returns every value in the document. $..price finds all price fields at any level of nesting.
How do I filter array items by a property value?▾
Use a filter expression: $.books[?(@.price < 10)] returns all book objects where price is less than 10. The @ symbol refers to the current element being tested. You can chain conditions: [?(@.price < 10 && @.inStock == true)].
Does JSONPath work on arrays at the root level?▾
Yes. If the root is an array, use $[*] to select all elements, $[0] for the first, or $[?(@.id == 5)] to filter. The $ root operator works on any JSON value — object or array.
What is the difference between JSONPath and XPath?▾
JSONPath was designed as a JSON analogue to XPath. Both use path expressions to navigate a document tree. Key differences: XPath operates on XML with namespaces and attributes; JSONPath operates on JSON with objects and arrays. JSONPath uses $ for root vs. / in XPath. JSONPath filter expressions use @; XPath predicates use position() and similar functions.
How do I extract a nested value using JSONPath in AWS Step Functions?▾
In Step Functions, use InputPath to select a portion of the input JSON before passing it to a state: set InputPath to $.order.items[0] to pass only the first item. Use ResultPath to store the result at a path in the state output. Use Parameters to construct a new object with specific fields: { "orderId.$": "$.order.id" }.
Related Tools
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.