Home › Developer Tools › JMESPath Tester

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:

Advertisement
Advertisement

How to use the JMESPath Tester

  1. Pick sample data (EC2, S3, people or orders) or paste your own JSON, for example the output of an AWS CLI command.
  2. Type a JMESPath expression in the query box, or click one of the example chips.
  3. Read the result on the right. The badge shows its type and size; null means nothing matched.
  4. Check the Parse tree tab if the result surprises you, to see how projections and pipes were grouped.
  5. Open the AWS CLI tab and copy the --query command with the right quotes for your shell.

JMESPath syntax cheat sheet

SyntaxWhat it doesExample
a.bSub-expression: the key b inside a; missing keys give nullState.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 endContents[-1]
[start:stop:step]Slice; stop is exclusive, every part optionalpeople[:2], items[::-1]
[*]List projection: apply the rest of the expression to every elementpeople[*].name
[]Flatten one level, then projectReservations[].Instances[]
.*Object projection over all values of an objectregions.*.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), notcity || '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 resultpeople[*].name | [0]
@The current nodelength(@)
`json`, 'raw'JSON literal and raw string literal`30`, `true`, 'prod'
&exprExpression reference, passed to sort_by, max_by, min_by, mapsort_by(Contents, &Size)

Built-in functions

FunctionReturns
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_byLargest 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_withPrefix 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, typeConversions and the type name
abs, ceil, floor, reverseMath 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, while Reservations[].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: --query filters after the response arrives. To reduce what AWS returns, combine it with --filters or 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.

Related tools

JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.Online Python CompilerRun Python 3 in your browser with input(), numpy, pandas, charts and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.Logic Gate SimulatorBuild logic circuits with AND, OR, NOT, XOR gates and flip-flops; see live outputs and truth tables.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.XSLT TesterRun an XSLT 1.0 stylesheet on XML in your browser and see the output as HTML, XML or text.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.Diff ViewerPaste a git diff or .patch file and view it side by side or inline, with file navigation.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.
See all 53 Code Playgrounds & Testers →