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 formatter highlights the error with the line number so you can fix it immediately.
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. The formatter detects Kibana-style prefix lines like GET /products/_search or POST /logs-*/_search and preserves them exactly as-is. Only the JSON body below the prefix is parsed and reformatted with proper indentation. This means you can paste queries directly from Kibana Dev Tools and the formatted output is ready to paste right back without any manual editing.
What is the difference between this and a JSON formatter?
A standard JSON Formatter would fail on the GET /index/_search prefix that Kibana uses, because that line is not valid JSON. This Elasticsearch-specific formatter understands that prefix convention, preserves it, and only formats the JSON body underneath. It also handles Elasticsearch-specific patterns like deeply nested bool queries and aggregation pipelines. For MongoDB queries, use the MongoDB Query Formatter. For DynamoDB, use the DynamoDB Query Formatter.
Can it format nested bool queries?
Absolutely. The formatter correctly indents deeply nested bool queries with must, should, filter, and must_not clauses at any depth. Each nesting level gets proper 2-space indentation, making complex boolean logic easy to read and debug. Even queries with bool inside bool — such as a must clause containing another bool with its own should — are formatted cleanly.
Does it validate the Elasticsearch query structure?
The formatter validates that your input is well-formed JSON. If there are syntax errors — a missing comma, unmatched brace, trailing comma, or invalid character — it highlights the error and shows the position so you can fix it quickly. This catches common issues before you send the query to your Elasticsearch cluster, saving you from cryptic parse errors in the response.
Can I minify an Elasticsearch query?
Yes. Click the Minify button to compress your query into a single compact line with no extra whitespace. This is useful when embedding queries in curl commands, storing them in configuration files, or passing them as string parameters in application code. You can also go the other direction — paste a minified query and the formatter will expand it into readable, indented output.
Does it support aggregations formatting?
Yes. The formatter handles all Elasticsearch aggregation types including terms, date_histogram, range, nested, and pipeline aggregations like avg_bucket. Sub-aggregations (the aggs key inside another aggregation) are properly indented under their parent, making complex multi-level aggregation pipelines easy to understand and modify.
Is this formatter free?
Completely free with no limits on usage. No account or registration required. All processing happens entirely in your browser — your queries never leave your machine. Also check out: SQL to Elasticsearch, Elasticsearch to SQL, and 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