SQL to Elasticsearch Converter Online — Convert SQL to Elasticsearch DSL Queries
Paste your SQL query above and get the equivalent Elasticsearch DSL query instantly. Converts WHERE to bool queries, LIKE to wildcards, GROUP BY to aggregations — all in your browser. Everything runs client-side using JavaScript, so your queries never leave your machine.
How to Convert SQL to Elasticsearch — Step-by-Step
Input Your SQL Query
Need to query Elasticsearch but only know SQL? Paste your SELECT query and the converter handles the translation to Elasticsearch's JSON-based Search API.
.sql fileExample SQL Input
A typical query selecting products with filters, sorting, and a row limit:
SELECT name, price FROM products WHERE category = 'electronics' AND price > 50 ORDER BY price ASC LIMIT 20
Automatic Conversion to Elasticsearch DSL
The converter maps each SQL clause to its Elasticsearch Query DSL equivalent:
_source array to return only the fields you needbool.must with term, range, terms, wildcard, and exists queries%text% becomes wildcard, text% becomes prefixsort array with field and order directionsize and from parameters for paginationElasticsearch DSL Output
The SQL query from Step 1 converts to this Elasticsearch request body:
// GET /products/_search { "_source": ["name", "price"], "query": { "bool": { "must": [ { "term": { "category": "electronics" } }, { "range": { "price": { "gt": 50 } } } ] } }, "sort": [{ "price": "asc" }], "size": 20 }
GROUP BY & Aggregation Conversion
SQL GROUP BY with aggregate functions maps to Elasticsearch terms aggregations with nested sub-aggregations. The converter handles COUNT, SUM, AVG, MIN, and MAX automatically.
SQL with GROUP BY
SELECT category, COUNT(*) AS total, SUM(price) AS revenue FROM products GROUP BY category
Elasticsearch Aggregation Output
{ "size": 0, "aggs": { "group_by_category": { "terms": { "field": "category" }, "aggs": { "total": { "value_count": { "field": "_id" } }, "revenue": { "sum": { "field": "price" } } } } } }
Notice that size: 0 is set because aggregation queries typically don't need individual hits — only the bucket results. Each SQL aggregate function maps to its Elasticsearch metric aggregation equivalent.
Copy or Download
Once you have the converted Elasticsearch DSL, export it in the way that suits your workflow:
.json file for version control or sharing with your teamFrequently Asked Questions — SQL to Elasticsearch
What SQL features are supported?
The converter supports SELECT with column selection (mapped to _source), WHERE with all comparison operators (=, !=, >, <, >=, <=), LIKE (to wildcard/prefix), IN (to terms), BETWEEN (to range), IS NULL/IS NOT NULL (to exists), AND/OR boolean logic, GROUP BY with aggregate functions (COUNT, SUM, AVG, MIN, MAX), ORDER BY with ASC/DESC, LIMIT, and OFFSET.
Does Elasticsearch support JOINs?
No — Elasticsearch is a search and analytics engine, not a relational database. It doesn't support SQL-style JOINs. The standard approach is to denormalize your data by flattening related records into a single index at index time. For use cases where you need relationships, consider nested objects or parent-child mappings. If you need JOIN support, try SQL to MongoDB which supports $lookup.
Can I use the output in Kibana?
Yes — the output includes the GET /index/_search line and the JSON body, which you can paste directly into Kibana Dev Tools console. Open Kibana, navigate to Management > Dev Tools (or press Ctrl+/), paste the output, and click the green play button to execute. The response appears in the right pane with your query results formatted as JSON.
How does GROUP BY convert to aggregations?
SQL GROUP BY maps to an Elasticsearch terms aggregation that creates buckets for each unique value. Aggregate functions become sub-aggregations: COUNT(*) becomes value_count, SUM(field) becomes sum, AVG(field) becomes avg, and MIN/MAX map directly. The converter also sets size: 0 since aggregation-only queries don't need individual document hits.
Does it handle LIKE queries?
Yes. SQL LIKE patterns are mapped to the most efficient Elasticsearch query type. A pattern like %text% (contains) becomes a wildcard query with *text*. A pattern like text% (starts with) becomes a prefix query, which is significantly faster because it can use the inverted index directly. The _ single-character wildcard is mapped to ? in Elasticsearch syntax.
Is my data sent to a server?
No. All conversion happens entirely in your browser using client-side JavaScript. Your SQL queries never leave your machine — there are no API calls, no server-side processing, and nothing is logged or stored. This makes it safe to use with proprietary queries and internal schema names.
Is this converter free?
Completely free with no limits on usage. No account or registration required — convert as many SQL queries as you need. Also check out: Elasticsearch to SQL, SQL to MongoDB, SQL to DynamoDB, and MongoDB Query Formatter.
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