JSON Formatter
Format, validate, minify, and analyze JSON in one place.
Write a JSONPath expression and see the matching values from your JSON instantly. Start from the built-in examples or type your own query, and the live results update as you go. Everything is evaluated client-side in your browser, so your JSON never leaves your device.
JSONPath is a query language for JSON. If you have used XPath to pluck nodes out of an XML document, JSONPath is the same idea carried over to JSON: a compact expression that describes a path through the data and returns whatever matches. It was proposed by Stefan Goessner back in 2007, and the syntax he sketched out then is still the core of every implementation you will meet today, including the one running on this page.
The appeal is that you can pull exactly the values you care about out of a large, deeply nested document without writing a loop or hand-walking the tree. You write one line, you get a list of matches back, and you move on.
Most of JSONPath comes down to a handful of building blocks that you combine into a path. Here is the set you will use ninety percent of the time:
| Syntax | Meaning | Example |
|---|---|---|
| $ | The root of the document | $ |
| .key | A named child property | $.store |
| ['key'] | A child by bracket notation | $['store'] |
| [n] | An element at a given array index | $.book[0] |
| [*] | A wildcard matching every element | $.book[*] |
| .. | Recursive descent at any depth | $..price |
| [start:end] | A slice of an array | $.book[0:2] |
| [-1:] | The last element of an array | $.book[-1:] |
| [?(@.price < 10)] | A filter, where @ is the current node | $.book[?(@.price < 10)] |
Say you are querying a small book store document, an object with a store that holds an array of book objects (each with a title, author, and price) and a single bicycle. These queries show how the pieces fit together:
Once the syntax clicks you start seeing places to use it everywhere. Extracting a few fields from an API response is the everyday case, especially when the payload is big and you only want the ids or the prices. Config and CI tools lean on it heavily, letting you reference a value deep in a settings file without duplicating the whole structure. Log processing pipelines use it to fish specific attributes out of structured JSON logs.
Test frameworks are another big one: many assertion libraries let you write a JSONPath expression and check that the value it returns matches what you expect, which keeps response assertions short and readable. It is worth knowing that jq, the command-line JSON processor, solves the same problem with a related but different syntax, so a JSONPath expression will not drop straight into jq, though the mental model transfers cleanly.
Every expression here is evaluated locally in your browser, so your JSON never leaves your device. Want to reshape or inspect the data next? Pair this with the JSON formatter and JSON viewer from the toolkit.