# JMESPath Query Tool

Filter and reshape JSON with a JMESPath expression locally in your browser, including AWS CLI --query style projections, filters, functions, and raw output.

## Run it

- **CLI:** `gizza tool jmespath-query 'people[?age > `30`].{name: name, state: state}' 'json={"people":[{"name":"Alice","age":34,"state":"WA"},{"name":"Bob","age":25,"state":"OR"},{"name":"Carol","age":41,"state":"WA"}]}'`
- **Web:** https://gizza.ai/tools/jmespath-query/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/jmespath-query/tool.json

## Inputs

- `expression` — JMESPath expression _(field)_
- `json` — JSON document _(field)_
- `pretty` — Pretty-print JSON _(field)_
- `raw` — Raw strings / lines _(field)_

## Output

- JMESPath result (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `expression` — JMESPath expression
- `json` — JSON document
- `pretty` — Pretty-print JSON
- `raw` — Raw strings / lines

Example: `https://gizza.ai/tools/jmespath-query/?expression=people%5B%3Fage%20%3E%20%6030%60%5D.%7Bname%3A%20name%2C%20state%3A%20state%7D&json=%7B%22people%22%3A%5B%7B%22name%22%3A%22Alice%22%2C%22age%22%3A34%2C%22state%22%3A%22WA%22%7D%2C%7B%22name%22%3A%22Bob%22%2C%22age%22%3A25%2C%22state%22%3A%22OR%22%7D%2C%7B%22name%22%3A%22Carol%22%2C%22age%22%3A41%2C%22state%22%3A%22WA%22%7D%5D%7D&pretty=true&raw=true`

---

## About this tool

JMESPath is the JSON query language used by the AWS CLI `--query` flag. Paste a JSON document, enter an expression, and this tool evaluates it locally with a pure Rust engine. Use it to project fields, filter arrays, sort data, call built-in functions, or reshape objects before pasting the expression into scripts and CLI commands.

Worked examples:

```text
people[*].name
people[?age > `30`].{name: name, state: state}
sort_by(people, &age)[0].name
```

String literals use single quotes, JSON literals use backticks, and a missing match returns `null` rather than an error. Turn on raw output to print string results without JSON quotes and array items one per line.

Common built-ins supported by the underlying engine include `length`, `contains`, `starts_with`, `ends_with`, `sort`, `sort_by`, `max_by`, `min_by`, `join`, `keys`, `values`, `reverse`, `sum`, `avg`, `map`, `to_string`, and `to_number`.

Limits and edge cases: the page does not fetch remote URLs or contact AWS; it evaluates only the JSON you paste. Large documents must fit in browser memory. Syntax errors and type errors are reported separately from invalid JSON so you can tell which side needs fixing.

## FAQ

<details>
<summary>How is JMESPath different from JSONPath?</summary>

JSONPath focuses on selecting paths from a JSON tree. JMESPath also selects data, but it has a standardized expression language for projections, filters, pipes, functions, and object/list construction. It is the syntax used by `aws --query`.

</details>

<details>
<summary>What does raw output do?</summary>

Raw output is useful when your expression returns strings. A string result is printed without JSON quotes, and a top-level array is printed one item per line. Objects, numbers, booleans, and null still render as JSON-compatible text.

</details>

<details>
<summary>Why did my expression return null?</summary>

`null` is a valid JMESPath result. It usually means the path did not exist or a filter matched no object in the place you expected. Try projecting a smaller expression first, such as `people` or `people[*]`, then add filters one at a time.

</details>

<details>
<summary>Does this upload my JSON?</summary>

No. The evaluator runs as WebAssembly in your browser for the page surface, and the CLI/chat surfaces use the same local core. The tool has no live price, cloud, or account connection.

</details>

<details>
<summary>Can it generate code for my programming language?</summary>

No. This tool evaluates and debugs the expression itself. Once the expression works, paste it into the AWS CLI or a JMESPath library for your language.

</details>

## Related tools

- [MongoDB Extended JSON Converter](https://gizza.ai/tools/bson-extended-json-converter/): Convert MongoDB Extended JSON ($oid, $date, $numberLong) to and from plain JSON, with canonical or relaxed output, in your browser.
- [CSV Cell Diff](https://gizza.ai/tools/csv-cell-diff/): Compare two CSVs column-by-column and highlight every individual cell that changed, plus added and removed rows and columns.
- [DynamoDB JSON Converter](https://gizza.ai/tools/dynamodb-json-converter/): Convert between DynamoDB typed AttributeValue JSON and plain JSON in both directions, with auto-detect and pretty or compact output.
- [Elasticsearch Bulk Formatter](https://gizza.ai/tools/elasticsearch-bulk-formatter/): Build a compact Elasticsearch _bulk API body from a JSON array. Choose index/create/update/delete, _index, _id field, and doc_as_upsert locally.
- [JSON Assertion Runner](https://gizza.ai/tools/json-assertion-runner/): Run JSONPath assertions against a JSON payload and get a pass/fail report for tests, fixtures, and API responses.
