Loading...
Please wait a moment

GraphQL to Elasticsearch Converter Online — Convert GraphQL Queries to ES DSL

Paste your GraphQL query above and get the equivalent Elasticsearch DSL request. It converts field selections to _source filters, arguments to bool query conditions, and pagination args to size/from — all processed entirely in your browser.

How to Convert GraphQL to Elasticsearch — Step-by-Step

Step 1

Input Your GraphQL Query

Building an Elasticsearch backend for your GraphQL API? Paste your query from a GraphiQL playground, Apollo Explorer, or application code.

•
Paste: Copy your GraphQL query and paste it; the result updates as you type
•
Upload: Select a .graphql or .gql file
•
Sample: See a query with arguments, sorting, and field selections converted
Step 2

Automatic Conversion

The converter maps GraphQL concepts to Elasticsearch Search API:

•
Root field name: Becomes the index name in GET /index/_search
•
Field selections: Become the _source array
•
String arguments: Become match conditions, numbers and booleans become term, lists become terms
•
orderBy / limit / offset: Become sort, size, from
Step 3

Copy or Download

•
Copy: Paste into Kibana Dev Tools or your Elasticsearch client
•
Download: Save as elasticsearch-query.txt

Frequently Asked Questions

How does a GraphQL query map to Elasticsearch?

Each top-level field is read as an index name, so products(status: "active") { name price } becomes GET /products/_search with a bool query on status and a _source list of name and price. A nested selection such as address { city } is treated as an object inside the document and becomes address.city in _source. Elasticsearch only accepts lowercase index names that do not start with an underscore, so Products or _logs are changed to products and logs, with a comment above the request saying so.

Which arguments become match, term, terms or range?

Strings and enum values become match clauses, numbers and booleans become term clauses, and lists become terms. An object made only of gt, gte, lt and lte, like price: { gte: 10, lte: 100 }, becomes a range clause. Any other object is read field by field, so address: { city: "Oslo" } matches address.city. A null value becomes a must_not exists check.

How are sorting and pagination handled?

orderBy and sortBy become sort. They can be a string such as "price DESC", an object such as { price: DESC, name: ASC }, or a list of those. limit and first become size, offset and skip become from. Everything else ends up in the query.

Are long IDs and decimals kept exactly?

Yes. The JSON body is written straight from the text of your query, so an ICCID like 8901240544102066246 stays a bare number with every digit, 14.50 stays 14.50, and a quoted value such as "00501" stays a string. Strings with quotes, backslashes or emoji are escaped so the body is valid JSON.

Can it convert mutations, variables or fragments?

Fragments and inline fragments are expanded into the fields they contain, and comments are ignored. Mutations and subscriptions are refused with a message, since they have no _search equivalent. A variable such as $id has no value inside the query text, so you are asked to replace it with the real value first.

Does my query leave the browser?

No. The query is parsed with the graphql-js library inside your browser and nothing is uploaded. The result is plain text in the Kibana Dev Tools format, so Download saves it as elasticsearch-query.txt. It costs nothing and needs no account.

Also try: GraphQL to SQL, GraphQL to MongoDB, MongoDB to GraphQL, GraphQL to REST, GraphQL Formatter.