Both JMESPath and JSONPath let you query JSON data without writing code. But they're different languages with different strengths. Here's how to choose.
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
Filtering
JSONPath: [?(@.price < 10)] — uses @ to reference the current item
JMESPath: [?price < `10`] — simpler syntax, no @ needed
Transformations
JSONPath: Limited. Can select and filter, but not much else.
JMESPath: Rich. Can map, flatten, group, and combine data.
Functions
JSONPath: No built-in functions.
JMESPath: Includes functions like length(), keys(), sort(), join(), and more.
Syntax
JSONPath: Closer to XPath. Familiar if you know XML.
JMESPath: More like a programming language. Easier to read if you're used to code.
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.