JMESPath Tester
Type a JMESPath expression and see the result instantly. Try it on realistic AWS CLI output (EC2 instances, S3 objects) or paste your own JSON, then copy a ready-to-run --query command for Bash, PowerShell or cmd.
Last updated:
Use the expression with any AWS CLI command through --query. Quoting differs by shell:
Add --output table or --output text to change the format; the query itself is the same.
How to use the JMESPath Tester
- Pick sample data (EC2, S3, people or orders) or paste your own JSON, for example the output of an AWS CLI command.
- Type a JMESPath expression in the query box, or click one of the example chips.
- Read the result on the right. The badge shows its type and size; null means nothing matched.
- Check the Parse tree tab if the result surprises you, to see how projections and pipes were grouped.
- Open the AWS CLI tab and copy the --query command with the right quotes for your shell.
JMESPath syntax cheat sheet
| Syntax | What it does | Example |
|---|---|---|
a.b | Sub-expression: the key b inside a; missing keys give null | State.Name |
"key-name" | Quoted identifier for keys with spaces, dashes or leading digits | "first-name" |
[0], [-1] | Index into a list; negative counts from the end | Contents[-1] |
[start:stop:step] | Slice; stop is exclusive, every part optional | people[:2], items[::-1] |
[*] | List projection: apply the rest of the expression to every element | people[*].name |
[] | Flatten one level, then project | Reservations[].Instances[] |
.* | Object projection over all values of an object | regions.*.endpoint |
[?expr] | Filter projection: keep elements where expr is truthy | [?Size > `1000`] |
== != < <= > >= | Comparisons; ordering works on numbers only | [?age >= `18`] |
&& || ! | And, or (returns the first truthy value), not | city || 'unknown' |
[a, b] | Multiselect list: build an array per element | [InstanceId, State.Name] |
{k: a} | Multiselect hash: build an object with new key names | {ID: InstanceId} |
| | Pipe: stop the projection and apply the right side to the whole result | people[*].name | [0] |
@ | The current node | length(@) |
`json`, 'raw' | JSON literal and raw string literal | `30`, `true`, 'prod' |
&expr | Expression reference, passed to sort_by, max_by, min_by, map | sort_by(Contents, &Size) |
Built-in functions
| Function | Returns |
|---|---|
length(x) | Characters in a string, items in a list, or keys in an object |
sort(list), sort_by(list, &key) | Sorted list (numbers or strings only; sort_by is stable) |
max, min, max_by, min_by | Largest or smallest value or element (null for an empty list) |
sum(list), avg(list) | Total and mean of a list of numbers |
contains(list|string, value) | True if the list has the value or the string has the substring |
starts_with, ends_with | Prefix and suffix tests on strings |
join(sep, list) | Join a list of strings into one string |
keys(obj), values(obj), merge(a, b, …) | Object keys, values, and a shallow merge (later wins) |
map(&expr, list) | Apply an expression to every element, keeping nulls |
not_null(a, b, …) | First argument that is not null |
to_string, to_number, to_array, type | Conversions and the type name |
abs, ceil, floor, reverse | Math helpers and reversing a list or string |
Tips for AWS CLI queries
- Projections stop at a pipe.
Reservations[].Instances[].Tags[0]returns the first tag of every instance, whileReservations[].Instances[].Tags | [0]returns the whole tag list of the first instance only. - Reading tags:
Tags[?Key=='Name'].Value | [0]turns the AWS key/value tag list into a single name. - Truthiness:
false,null, empty strings, empty lists and empty objects are false; the number 0 is true. - Server side or client side:
--queryfilters after the response arrives. To reduce what AWS returns, combine it with--filtersor the command's own server-side options. - Output table: a multiselect hash such as
{ID: InstanceId, Type: InstanceType}gives nicely labelled columns with--output table.
Frequently asked questions
What is JMESPath?
JMESPath (pronounced James path) is a query language for JSON with a formal specification and a compliance test suite, so the same expression gives the same result in Python, JavaScript, Go, Java and other implementations. It is the language behind the AWS CLI --query option and the Azure CLI --query option.
How do I use JMESPath with the AWS CLI?
Add --query followed by the expression, for example aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'. The CLI applies the expression to the JSON response on your machine before printing it, so you can combine it with --output table or --output text. Test the expression here first, then copy it from the AWS CLI tab.
Why do I need backticks around numbers?
In JMESPath a bare number is not a value, so [?age > 30] is a syntax error. JSON literals go inside backticks: [?age > `30`]. Strings can use raw string quotes instead: [?name == 'Ava']. Double quotes are for identifiers that contain special characters, like "first-name".
What is the difference between [*] and []?
Both create a projection over a list. [*] keeps the structure, so Reservations[*].Instances[*].InstanceId returns a list of lists. [] also flattens one level, so Reservations[].Instances[].InstanceId returns a single flat list of IDs, which is usually what you want with AWS output.
Why does my filter return an empty list or null?
A missing key returns null instead of an error, and ordering comparisons like < only work on numbers. Common causes: a typo or wrong letter case in a key name, comparing a number to a string such as `"30"`, applying a filter to an object instead of a list, or forgetting the backticks around a number.
How is JMESPath different from JSONPath and jq?
JSONPath only selects existing values and its behaviour varies between libraries (it was standardized late, as RFC 9535). JMESPath can also reshape results with multiselect hashes and built-in functions, and every implementation follows one spec. jq is a full programming language with variables and arithmetic, but it is a separate command-line tool rather than something built into the AWS and Azure CLIs.
Is my JSON sent anywhere?
No. The JMESPath engine is plain JavaScript running inside this page. Your JSON, including any AWS resource details, stays in your browser.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.