JMESPath is the JSON query language built into the AWS CLI, boto3 and many other tools. When you pass --query to an aws command, the string you supply is a JMESPath expression that filters and reshapes the JSON response. This tester evaluates those expressions live against your own JSON so you can perfect a --query before running it against a real account.
How it works
A JMESPath expression is read left to right. The most important building block is the projection, which applies the rest of the expression to every element of a list or object:
Reservations[].Instances[].InstanceId
Here Reservations[] flattens the list of reservations, Instances[] flattens the instances inside each, and .InstanceId is then applied to every instance, producing a flat list of IDs. A filter projection narrows a list:
Instances[?State == `running`].InstanceId
keeps only the instances whose State equals the literal running (literals go inside backticks), then projects out their IDs. A pipe stops a projection and starts a new expression on its result:
Instances[].Cpu | max(@)
projects every CPU value, then max(@) runs once on the resulting array, where @ means “the current value”.
Functions and multiselect
The standard function library lets you reshape and aggregate: length(@), sort_by(Instances, &Cpu), join(', ', Names), contains(Tags, 'prod'), sum(Costs) and more. A multiselect hash rebuilds objects with only the fields you want:
Instances[].{id: InstanceId, cpu: Cpu}
returns a list of small objects, each containing just id and cpu.
Tips
- Wrap literal values in backticks:
State == \running`,Count == `3`. Bare quotes’text’` are raw strings and also work in comparisons. - Use
[]to flatten nested lists and[*]to project a single level. They behave differently when the data is nested, so reach for[]when AWS wraps results in an extra list (as it does withReservations). - Build the expression incrementally. Start with
Reservations[], confirm the shape, then append the next segment.