Loading...

SQL to Elasticsearch Query Converter Online — SQL to Query DSL Free

Convert SQL SELECT statements into Elasticsearch Query DSL JSON instantly, right in your browser. Translates WHERE clauses (AND/OR, IN, BETWEEN, LIKE, IS NULL, comparisons) into bool/term/range/terms/wildcard queries, plus ORDER BY into sort and LIMIT/OFFSET into size/from. Constructs with no direct Elasticsearch equivalent — JOINs, GROUP BY, HAVING, aggregate functions — are called out as warnings instead of being silently dropped, so you know exactly what still needs manual work.

Features

  • WHERE Clause to Bool Query

    Maps AND/OR to bool must/should, comparisons to term/range, IN to terms, LIKE to wildcard, and IS (NOT) NULL to exists queries.

  • ORDER BY, LIMIT & OFFSET

    Converts ORDER BY into an Elasticsearch sort array and LIMIT/OFFSET (including MySQL comma syntax) into size/from.

  • Honest About What It Can't Convert

    JOINs, GROUP BY, HAVING, DISTINCT, and aggregate functions have no 1:1 Elasticsearch DSL equivalent — the tool flags them as warnings rather than guessing.

  • 100% Client-Side Privacy

    Queries, table names, and column names are parsed locally in your browser and never sent to any server.

How to Convert a SQL Query to Elasticsearch Query DSL

A step-by-step guide to translating a SQL SELECT statement into Elasticsearch JSON:

  1. Paste a SQL SELECT QueryPaste your SQL SELECT statement into the left editor, or click "Sample Query" to try an example.
  2. Pick the Source SQL DialectChoose the dialect your query is written in (MySQL, PostgreSQL, SQLite, T-SQL, BigQuery) for accurate parsing.
  3. Review the Generated Query DSLThe Elasticsearch Search API request body appears on the right automatically. Check the warnings bar for anything that needs manual attention, then copy or download the JSON.

Examples

Simple WHERE with AND

Input
SELECT id, name FROM users WHERE status = 'active' AND age >= 18
Output
{
  "query": {
    "bool": {
      "must": [
        { "term": { "status": "active" } },
        { "range": { "age": { "gte": 18 } } }
      ]
    }
  },
  "_source": ["id", "name"]
}

IN and LIKE

Input
SELECT * FROM products WHERE category IN ('books','games') AND sku LIKE 'SKU-%'
Output
{
  "query": {
    "bool": {
      "must": [
        { "terms": { "category": ["books", "games"] } },
        { "wildcard": { "sku": "SKU-*" } }
      ]
    }
  }
}

Frequently Asked Questions

Are my SQL queries or schema sent to a server?
No. Parsing and conversion run 100% client-side in your browser. Nothing is transmitted or logged.
Can this convert JOINs or subqueries?
No — Elasticsearch documents are independent and not relational, so JOINs have no direct Query DSL equivalent. The tool warns you instead of producing an incorrect query; consider denormalizing your documents or using nested/join field types.
What happens to GROUP BY, HAVING, and aggregate functions like COUNT()?
These map to Elasticsearch aggregations (terms, date_histogram, metric aggs), not to the query clause, so they are not auto-converted. The tool flags them as a warning so you can add the aggregation yourself.
Which SQL operators are supported in WHERE clauses?
=, !=/<>, >, >=, <, <=, LIKE/NOT LIKE, IN/NOT IN, BETWEEN/NOT BETWEEN, IS (NOT) NULL, AND, OR, and NOT — nested with parentheses.
Does ORDER BY and LIMIT work?
Yes. ORDER BY becomes a sort array, and LIMIT/OFFSET (both ANSI and MySQL comma syntax) becomes size/from in the Elasticsearch request body.