Write a JMESPath expression and see its result on your JSON as you type. JMESPath is the language of the --query option in the AWS CLI and the Azure CLI, so you can get an expression right on a saved response before you run the command again. To compare with JSONPath on the same data, use the JSONPath Tester.
How to use it
- Start from an example, such as aws ec2 describe-instances, or paste your own JSON with Edit or Open file.
- Pick an "I want to" pattern, click a line of the data to put its path in the query, or type: suggestions come from the data.
- Read the result as JSON, a table or text. Explain shows each step, and a hint offers a fix when a query fails or finds nothing.
- Copy for… gives the query as an AWS CLI, Azure CLI, Ansible or Python command.
Read more: n8n $json expressions explained: paths, items and $jmespath · jq vs JSONPath vs JMESPath: the same 8 tasks in all three
Private, and made for big files
This tool runs in your browser, in a background worker: nothing you paste or open is uploaded, and nothing is kept after you leave. JSON and XML input can be up to 1 GB, depending on available memory. Processing runs in a background worker; large analyses can take a minute or more. Already loaded features keep working if your connection drops. Loading another tool or jq for the first time needs a connection. When one tool isn't enough, GigaJSON opens your data with a tree, a table, JSONPath/JMESPath/jq queries, transforms, diff and history.
JMESPath syntax, with examples
Each example runs on the aws ec2 describe-instances data in the playground, and shows its real result. Try it loads the example above, so you can change it and watch the result.
field Take a field
Reservations[0].ReservationId"r-0a1b2c3d4e5f60718"a.b A field inside a field
Reservations[0].Instances[0].State.Name"running"[0] [-1] One item by position. -1 is the last
Reservations[0].Instances[-1].InstanceId"i-07c1d8e2a4b6f9e02"[start:stop] A slice of a list
Reservations[0].Instances[:1].InstanceId[
"i-0f3a9c2e7b1d45e01"
][*] Every item. What follows runs on each one (a projection)
Reservations[*].ReservationId[
"r-0a1b2c3d4e5f60718",
"r-09f8e7d6c5b4a3921"
][] Every item, with nested lists flattened into one list
Reservations[].Instances[].InstanceId[
"i-0f3a9c2e7b1d45e01",
"i-07c1d8e2a4b6f9e02",
"i-0b5e2f7a9c3d18e03"
][?condition] Keep the items where the condition is true
Reservations[].Instances[?State.Name 'running'][].InstanceId[
"i-0f3a9c2e7b1d45e01",
"i-0b5e2f7a9c3d18e03"
]== != < <= > >= Compare. Numbers go in backticks
Reservations[].Instances[?CpuOptions.CoreCount `1`][].InstanceId[
"i-0b5e2f7a9c3d18e03"
]&& || ! And, or, not
Reservations[].Instances[?State.Name 'running' InstanceType 't3.micro'][].InstanceId[
"i-0b5e2f7a9c3d18e03"
]{name: expr} Build an object for each item
Reservations[].Instances[].{id: InstanceId, state: State.Name}[
{
"id": "i-0f3a9c2e7b1d45e01",
"state": "running"
},
{
"id": "i-07c1d8e2a4b6f9e02",
…[expr, expr] Build a list for each item
Reservations[].Instances[].[InstanceId, InstanceType][["i-0f3a9c2e7b1d45e01","t3.micro"],["i-07c1d8e2a4b6f9e02","m5.large"],["i-0b5e2f7a9c3d18e03","c6i.xlarge"]]| Pipe: end the projection and work on the whole result
Reservations[].Instances[].InstanceId [0]"i-0f3a9c2e7b1d45e01"@ The current value
Reservations[].Instances[].InstanceType sort()[
"c6i.xlarge",
"m5.large",
"t3.micro"
]'text' `json` A string, and a JSON literal such as a number or true
length(Reservations[].Instances[?CpuOptions.ThreadsPerCore `2` State.Name 'running'][])2JMESPath functions
Functions take arguments in parentheses. The ones that sort or pick by a field (sort_by, max_by, min_by, map) take it with & in front.
length() How many items, keys or characters
length(Reservations[].Instances[])3sort_by() Sort a list by a field (note the &)
sort_by(Reservations[].Instances[], LaunchTime)[].InstanceId[
"i-07c1d8e2a4b6f9e02",
"i-0f3a9c2e7b1d45e01",
"i-0b5e2f7a9c3d18e03"
]max_by() min_by() The item with the largest or smallest value
max_by(Reservations[].Instances[], CpuOptions.CoreCount).InstanceId"i-0b5e2f7a9c3d18e03"contains() A string contains text, or a list contains a value
Reservations[].Instances[?contains(InstanceType, 'large')][].InstanceId[
"i-07c1d8e2a4b6f9e02",
"i-0b5e2f7a9c3d18e03"
]starts_with() ends_with() A string starts or ends with text
Reservations[].Instances[?starts_with(InstanceType, 't3')][].InstanceId[
"i-0f3a9c2e7b1d45e01"
]join() Join strings into one
join(', ', Reservations[].Instances[].InstanceType)"t3.micro, m5.large, c6i.xlarge"sum() avg() Add up or average numbers
sum(Reservations[].Instances[].CpuOptions.CoreCount)4keys() values() The keys or values of an object
keys(Reservations[0].Instances[0])["InstanceId","InstanceType","State","PrivateIpAddress","LaunchTime","CpuOptions","Tags"]map() Apply an expression to each item
map(InstanceType, Reservations[].Instances[])[
"t3.micro",
"m5.large",
"c6i.xlarge"
]to_string() to_number() Convert a value
Reservations[].Instances[].to_string(CpuOptions.CoreCount)[
"1",
"1",
"2"
]AWS CLI and Azure CLI --query recipes
The AWS CLI and the Azure CLI filter their output with the same JMESPath. Each recipe is a full command, quoted for bash and zsh, with its result on the example data. In PowerShell, put the query in single quotes and double any single quotes inside it; Copy for… in the playground does this for you.
The IDs of running instances
aws ec2 describe-instances --query "Reservations[].Instances[?State.Name=='running'][].InstanceId" --output json[
"i-0f3a9c2e7b1d45e01",
"i-0b5e2f7a9c3d18e03"
]Add --output text to get the IDs on one line, ready for another command.
Each instance's Name tag
aws ec2 describe-instances --query "Reservations[].Instances[].Tags[?Key=='Name'].Value | []" --output json[
"web-1",
"batch-worker",
"api-1"
]Tags are a list of Key/Value pairs, so the tag is found with a filter. | [] turns the list of lists into one list.
Instance ID next to its Name tag
aws ec2 describe-instances --query "Reservations[].Instances[].{id: InstanceId, name: Tags[?Key=='Name'] | [0].Value}" --output json[
{
"id": "i-0f3a9c2e7b1d45e01",
"name": "web-1"
},
{
"id": "i-07c1d8e2a4b6f9e02",
…The most recently launched instance
aws ec2 describe-instances --query "sort_by(Reservations[].Instances[], &LaunchTime)[-1].InstanceId" --output json"i-0b5e2f7a9c3d18e03"LaunchTime is an ISO date, so sorting the text sorts by time.
How many instances are running
aws ec2 describe-instances --query "length(Reservations[].Instances[?State.Name=='running'][])" --output json2Instances of one family
aws ec2 describe-instances --query "Reservations[].Instances[?starts_with(InstanceType, 't3')][].InstanceId" --output json[
"i-0f3a9c2e7b1d45e01"
]Buckets whose names start with logs
aws s3api list-buckets --query "Buckets[?starts_with(Name, 'logs')].Name" --output json[
"logs-cloudtrail-eu",
"logs-alb-prod"
]The newest bucket
aws s3api list-buckets --query "sort_by(Buckets, &CreationDate)[-1].Name" --output json"prod-backups"Lambda functions on Python 3.12
aws lambda list-functions --query "Functions[?Runtime=='python3.12'].FunctionName" --output json[
"nightly-report",
"webhook-handler"
]Total memory of all Lambda functions
aws lambda list-functions --query "sum(Functions[].MemorySize)" --output json1792Azure VMs in one region
az vm list --show-details --query "[?location=='westeurope'].name" --output json[
"web-vm-01",
"build-agent"
]Running Azure VMs with their size
az vm list --show-details --query "[?powerState=='VM running'].{name: name, size: hardwareProfile.vmSize}" --output json[{"name":"web-vm-01","size":"Standard_B2s"},{"name":"db-vm-01","size":"Standard_D4s_v5"}]Common JMESPath errors and how to fix them
The messages come from the JMESPath this page runs and, for the AWS CLI, from Python's jmespath library, which the AWS CLI uses. The playground also spots these mistakes as you type and offers the fix.
Invalid token (Number), or Parse error … token "1" (NUMBER)
JMESPath writes numbers in backticks. Without them, 1 isn't a value the parser accepts at that point.
Reservations[].Instances[?CpuOptions.CoreCount 1][].InstanceIdReservations[].Instances[?CpuOptions.CoreCount `1`][].InstanceId- This playground
Invalid token (Number): "1"- AWS CLI
invalid token: Parse error at column 49, token "1" (NUMBER)
Nothing found with "double quotes"
In JMESPath, "running" in double quotes is a field called running, not text. The comparison never matches, so the result is empty. Text goes in single quotes.
Reservations[].Instances[?State.Name"running"][].InstanceIdReservations[].Instances[?State.Name'running'][].InstanceId- This playground
No error. The result is []
Unknown function: lenght()
Function names are spelled exactly, with underscores: sort_by, max_by, starts_with.
lenght(Reservations[].Instances[])length(Reservations[].Instances[])- This playground
Unknown function: lenght()- AWS CLI
Unknown function: lenght()
Expected Rbracket, or Incomplete expression
A [ is never closed. Every filter ends with ].
Reservations[].Instances[?State.Name'running'.InstanceIdReservations[].Instances[?State.Name'running'][].InstanceId- This playground
Expected Rbracket, got: EOF- AWS CLI
Invalid jmespath expression: Incomplete expression
An empty list from a field name in the wrong case
Field names are case-sensitive, and a field that isn't there gives null, so nothing is reported. AWS names start with a capital letter.
Reservations[].Instances[].instanceIdReservations[].Instances[].InstanceId- This playground
No error. The result is []
sort_by() expected argument 2 to be type expression
sort_by, max_by, min_by and map need an expression reference: the field with & in front.
sort_by(Reservations[].Instances[], LaunchTime)[].InstanceIdsort_by(Reservations[].Instances[], LaunchTime)[].InstanceId- This playground
TypeError: sort_by() expected argument 2 to be type expression but received type null instead.- AWS CLI
In function sort_by(), invalid type for value: None, expected one of: ['expref'], received: "null"
'>' not supported between instances of 'int' and 'str'
'1' in single quotes is text. The browser's JMESPath compares it anyway, but the AWS CLI stops with this error. Compare numbers with 1.
Reservations[].Instances[?CpuOptions.CoreCount '1'][].InstanceIdReservations[].Instances[?CpuOptions.CoreCount `1`][].InstanceId- This playground
No error. The result is ["i-0b5e2f7a9c3d18e03"]- AWS CLI
TypeError: '>' not supported between instances of 'int' and 'str'
A query with backticks breaks in bash
Inside double quotes, bash runs `…` as a command, so a number in backticks disappears before the AWS CLI sees the query. Put the whole query in single quotes. Copy for… picks the right quotes for you.
aws ec2 describe-instances --query 'Reservations[].Instances[?CpuOptions.CoreCount > `1`][].InstanceId'Questions
How do I use JMESPath with the AWS CLI?
Add --query with the expression to any command, in single quotes in bash: aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'. The CLI runs the query on the JSON before printing it, and --output text prints the values on one line. Test the query here first on a saved response.
How do I filter by a tag in the AWS CLI?
Tags are a list of Key and Value pairs, so filter that list: Reservations[].Instances[].Tags[?Key=='Name'].Value | []. To keep the instances that have a tag, filter the instances: Reservations[].Instances[?Tags[?Key=='env' && Value=='prod']][].InstanceId.
Why does my --query return an empty list?
Check for text in "double quotes" (JMESPath reads it as a field name, use 'single quotes'), a field name in the wrong case (InstanceId, not instanceId), or a filter that matches nothing. The playground spots the first two and offers the fix.
What is the difference between [] and [*]?
Both take every item and run what follows on each. [] also flattens nested lists into one list, so Reservations[].Instances[] gives one list of instances, while Reservations[*].Instances[*] gives a list per reservation.
What does a JMESPath expression look like?
items[0].name picks one value. items[*].name takes a field from every item. items[?price > `10`] filters, with literals in backticks. Functions such as length(), sort_by() and join() reshape the result, and | passes it to the next expression.
What is the difference between JMESPath and JSONPath?
JSONPath selects values by their path. JMESPath can also build new objects and lists from them, like {id: id, name: name}, and it has a written specification, so implementations agree on the result.
Is it the same JMESPath as the AWS CLI?
Yes. It uses the jmespath JavaScript library, which follows the same specification as the Python library inside the AWS CLI, so an expression gives the same result in both.
Is my data uploaded?
No. The tool runs in your browser, in a background worker. Nothing you paste or open goes to a server, and nothing is kept after you leave the page.
All tools
- JSON FormatterIndent with 2 or 4 spaces, sort keys
- JSON ValidatorLine and column of the first error
- JSON MinifierRemove whitespace, see the bytes saved
- JSON RepairFixes quotes, commas, comments, AI output
- JSON Schema GeneratorA JSON Schema from examples
- JSON Schema ValidatorCheck JSON against a schema
- JSON Token CounterCount tokens, select data, compare JSON and TOON
- JSON EditorTree and code editing, undo and history
- Large JSON ViewerTree, table and search for huge files
- JSON Lines ViewerJSONL and NDJSON logs as a table
- JSON Log ViewerCount and filter JSON Lines logs
- Large CSV ViewerCSV files too big for Excel, up to 1 GB
- JSON VisualizerThe data as a graph, PNG and SVG export
- JSON DiffChanges between two documents
- JSON Path FinderClick a value, copy its path
- JSONPath TesterJSONPath, JMESPath and jq, live
- JMESPath PlaygroundJMESPath, for AWS CLI queries too
- jq PlaygroundReal jq in your browser
- JSON to CSVNested objects become dotted columns
- JSON to ExcelAn .xlsx sheet, numbers kept as numbers
- CSV to JSONDelimiters detected, 007 stays 007
- JSON to XML@keys become attributes
- XML to JSONRSS feeds, sitemaps, SOAP responses
- JSON to YAMLReadable YAML, ambiguous strings quoted
- YAML to JSONAnchors and multiple documents
- JSON Lines to JSONNDJSON or JSONL into one array
- JSON to JSON LinesA JSON array as one record per line
- JSON to TOONConvert JSON to TOON, with token counts
- JSON to MermaidA flowchart or class diagram, drawn
- JSON SplitterCut a big file into parts, or sample it
- JSON to TypeScriptInterfaces inferred from your data
- JSON to GoGo structs with json tags
- JSON to RustRust structs that derive serde's Serialize and Deserialize
- JSON to PythonPython dataclasses with type hints
- JSON to JavaJava classes with getters and setters
- JSON to C#C# classes with System.Text.Json attributes
- JSON to KotlinKotlin data classes
- JSON to SwiftSwift structs that conform to Codable, with CodingKeys
- JSON to DartDart classes with fromJson and toJson
- JSON to ZodZod schemas with TypeScript types inferred from them
- JWT DecoderHeader, payload and expiry, locally
- JSON EscapeText to a JSON string and back
- Sample JSON FilesDownload test JSON, 100 KB to 1 GB
- Sample JSON Lines FilesDownload test NDJSON, one record per line
- Sample CSV FilesDownload test CSV, 100 KB to 1 GB
- Sample XML FilesDownload test XML, 100 KB to 1 GB
- Sample GeoJSON FilesPoints, lines and polygons, up to 1 GB
- Sample Nested JSONRecords 8 levels deep, up to 1 GB
- Sample Unicode JSON13 scripts, emoji and escapes
- Sample API ResponsesJSON:API, HAL, GraphQL, pages, errors
- Large JSON File GeneratorTest data from 100 KB to 1 GB