JSONPath and JMESPath are query languages that let you extract data from JSON without writing code. JSONPath, introduced by Stefan Goessner in 2007, uses a syntax modeled on XPath, with a leading $ to mark the document root (for example, $.store.book[0].title). JMESPath, specified at jmespath.org and used by the AWS CLI for its --query flag, drops the leading $ and adds a function library — length(), sort(), keys(), join(), and more — plus projections and transformations that let you reshape results as you query them. For simple selection both are equivalent: store.book[*].author returns every author either way. They diverge on complexity: JSONPath has broader library support across languages, while JMESPath offers a richer, more expressive grammar and a formal specification with multiple reference implementations. Choosing between them comes down to whether you need raw compatibility (JSONPath) or expressive power (JMESPath).
JSONPath basics
JSONPath is older and more widely supported. It uses a syntax similar to XPath (for XML):
$.store.book[0].title — get the title of the first book
$.store.book[*].author — get all authors
$.store.book[?(@.price < 10)] — get books under $10
JSONPath is simple and intuitive for basic queries. It's supported in many languages and tools.
JMESPath basics
JMESPath is newer and more powerful. It's the query language used by AWS CLI. Syntax is different:
store.book[0].title — get the title of the first book (no leading $)
store.book[*].author — get all authors
store.book[?price < `10`].author — get authors of books under $10
JMESPath supports more complex operations like filtering, projections, and transformations.
Key differences
| Feature | JSONPath | JMESPath |
|---|---|---|
| Filtering | [?(@.price < 10)] — uses @ for the current item | [?price < `10`] — no @ needed |
| Transformations | Limited — selects and filters only | Rich — map, flatten, group, combine |
| Functions | None built in | length(), keys(), sort(), join(), more |
| Syntax | Close to XPath; familiar if you know XML | More like a programming language |
| Specification | Community conventions (Goessner, 2007) | Formal spec at jmespath.org, reference implementations |
When to use each
Use JSONPath if: You need broad compatibility, you're working with simple queries, or you're in an environment that already supports it (many JavaScript libraries, for example).
Use JMESPath if: You need powerful transformations, you're using AWS CLI, or you want a more expressive query language. It's also the better choice if you're building tools for developers.
In practice
For most developers, JMESPath is the better choice today. It's more powerful, has better documentation, and is used by major tools like AWS CLI. JSONPath is still useful for simple queries and has broader library support.
If you're exploring JSON data and need to query it, try TOOlover's JSON Query tool — it supports JMESPath and lets you experiment without leaving your browser. The official JMESPath spec and Goessner's original JSONPath article are the authoritative references if you want to go deeper.