JMESPath

1.1.0 · active · verified Sat Mar 28

JMESPath (pronounced 'james path') is a query language for JSON that allows you to declaratively extract, filter, and transform elements from JSON documents or Python dictionaries. Current stable version is 1.0.0 (1.1.0 on PyPI as of 2026). The project is mature and low-churn — it reached 1.0 in 2022 with no breaking API changes, and releases are infrequent. It is a foundational dependency of boto3/botocore and is used by the AWS CLI --query flag.

Warnings

Install

Imports

Quickstart

One-shot search, compiled reuse, filter projection, and custom Options.

import jmespath
from jmespath import functions

# 1. One-shot search
data = {
    "people": [
        {"name": "Alice", "age": 30},
        {"name": "Bob",   "age": 17},
        {"name": "Carol", "age": 25},
    ]
}

# Returns all names
names = jmespath.search("people[*].name", data)
print(names)  # ['Alice', 'Bob', 'Carol']

# Filter: only adults
adults = jmespath.search("people[?age >= `18`].name", data)
print(adults)  # ['Alice', 'Carol']

# 2. Compile once, search many times (avoids re-parsing)
expr = jmespath.compile("people[*].age")
print(expr.search(data))  # [30, 17, 25]

# 3. Pipe to index into a projection result (not people[*].name[0]!)
first_name = jmespath.search("people[*].name | [0]", data)
print(first_name)  # 'Alice'

# 4. Custom function via Options
class MyFunctions(functions.Functions):
    @functions.signature({"types": ["string"]})
    def _func_upper(self, s):
        return s.upper()

opts = jmespath.Options(custom_functions=MyFunctions())
result = jmespath.search("people[0].name | upper(@)", data, opts)
print(result)  # 'ALICE'

view raw JSON →