Elasticsearch Query Formatter Online — Format & Beautify ES DSL Queries
Paste your Elasticsearch DSL query above and get clean, properly indented output instantly. Handles compact JSON, GET /index/_search prefixes, and bool queries with aggregations — all processed in your browser.
How to Format Elasticsearch Queries — Step-by-Step
Input Your Elasticsearch Query
Got a compact Elasticsearch query from Kibana Dev Tools, application logs, or API docs? Paste it in — the formatter preserves any GET /index/_search prefix and formats the JSON body.
.json fileExample: Compact Bool Query from Kibana
A typical compact Elasticsearch query copied from Kibana Dev Tools:
GET /products/_search {"query":{"bool":{"must":[{"match":{"title":"laptop"}}],"filter":[{"term":{"status":"active"}},{"range":{"price":{"gte":500,"lte":2000}}}]}},"size":20}
Automatic Formatting & Validation
The formatter parses your JSON, validates it, and outputs with proper 2-space indentation. Bool queries, nested aggregations, sort arrays, and _source fields are all properly structured. If your JSON has a syntax error — a missing comma, unmatched brace, or trailing comma — the output shows the line, column and reason so you can fix it right away. Only the JSON syntax is checked, not whether Elasticsearch accepts the query.
Example: Formatted Output
The same query from Step 1, now properly indented with clear structure:
GET /products/_search { "query": { "bool": { "must": [ { "match": { "title": "laptop" } } ], "filter": [ { "term": { "status": "active" } }, { "range": { "price": { "gte": 500, "lte": 2000 } } } ] } }, "size": 20 }
Minify for Production
Need to embed your Elasticsearch query in a curl command, config file, or application code? Click the Minify button to compress your formatted query into a single compact line with no extra whitespace. This is especially useful when passing queries as -d payloads in curl requests to the Elasticsearch REST API.
Example: Minified for curl
The formatted query compressed into a single line, ready to use in a curl command:
curl -X GET "localhost:9200/products/_search" -H 'Content-Type: application/json' -d' {"query":{"bool":{"must":[{"match":{"title":"laptop"}}],"filter":[{"term":{"status":"active"}},{"range":{"price":{"gte":500,"lte":2000}}}]}},"size":20} '
Copy or Download
Once your query looks right, grab the output and use it wherever you need:
.json file for version control or documentationFrequently Asked Questions
Does it handle GET /index/_search?
Yes. Paste straight from Kibana Dev Tools: request lines such as GET /products/_search, POST /logs-*/_search or GET _cat/indices?v are kept exactly as you typed them, and only the JSON body under each one is re-indented. Several requests in one paste work too, along with # comment lines between them. Bodies for _bulk or _msearch, which hold one JSON document per line, stay one document per line.
What is the difference between this and a JSON formatter?
A plain JSON formatter gives up on the first line of a Kibana request, because GET /index/_search isn't JSON. This page knows that convention, keeps the request lines and formats only the bodies. Inside a body nothing is special-cased: bool queries, aggregations and sort arrays are simply re-spaced, whatever their structure.
Can it format nested bool queries?
Yes. Every level of must, should, filter and must_not gets two more spaces of indentation, however deep the nesting goes, so a bool inside a should inside another bool stays easy to follow.
Does it validate the Elasticsearch query structure?
Only the JSON syntax. If a body has a missing comma, a stray brace or a trailing comma, you get the line and column (counted in the whole editor text) and a short reason. It doesn't know which query types or fields your cluster accepts, so a misspelled query name like mtach still formats cleanly and only fails once Elasticsearch sees it.
Can I minify an Elasticsearch query?
Yes. Minify puts each body on a single line with no spaces, which is handy for a curl -d payload or a config value. Request lines stay on their own line above the body. As soon as you type in the input again, the output goes back to the formatted view.
Will formatting change any of my values?
No. Bodies are re-spaced as text rather than parsed into numbers and printed again, so a long ID like 8901240544102066246 keeps every digit, 14.50 stays 14.50, escapes like \u0041 are left as written, and a key that appears twice stays twice.
Is this formatter free?
Yes, and there is nothing to sign up for. Formatting happens in your browser, so the query you paste isn't sent anywhere.
Working with other query languages? Try the JSON Formatter, MongoDB Query Formatter, DynamoDB Query Formatter, SQL to Elasticsearch, Elasticsearch to SQL or MongoDB to Elasticsearch.
Related Tools
SQL to MongoDB
Convert SQL queries to MongoDB query syntax with aggregation pipeline support
MongoDB to SQL
Convert MongoDB queries and aggregation pipelines to equivalent SQL statements
SQL to DynamoDB
Convert SQL queries to AWS DynamoDB query and scan operations with PartiQL support
DynamoDB to SQL
Convert AWS DynamoDB query and scan operations to equivalent SQL statements
MongoDB Query Formatter
Format, beautify, and validate MongoDB queries with proper indentation and syntax highlighting
MongoDB to DynamoDB
Convert MongoDB queries to AWS DynamoDB query operations and vice versa