Writing SQL is easy until the joins stack up, the date math gets fiddly, and you cannot remember whether this dialect uses DATE_TRUNC or DATEADD. This tool turns a plain-English description of what you want plus your table schema into a correct, dialect-specific query using your own OpenAI or Anthropic key, entirely in your browser.
How it works
Pick a provider and model, paste your API key, choose the SQL dialect you use, and paste your table definitions so the model works with your real column names. Then describe the result you want in plain English. The tool builds a focused prompt that tells the model to use only the tables you provided, prefer explicit joins, qualify ambiguous columns, and avoid SELECT *. It sends one direct request to the provider and returns a fenced SQL block followed by a short explanation of the query and any assumptions it made.
For Anthropic, the request includes the official direct-browser-access header so it works straight from the page.
Getting the best results
The single biggest quality lever is the schema. Paste the columns exactly as they exist — including types where they matter — so the model does not invent a purchase_date when your column is created_at. Be specific about filters and grouping in your description: “last 90 days” beats “recently”, and “one row per customer” beats “by customer”. For analytical queries, name the metric and the dimension explicitly, for example “total revenue (sum of orders.total) grouped by month”.
Notes and limits
The generated SQL is a draft, not a guarantee. Models can hallucinate columns, miss an edge case in a filter, or pick a less efficient plan than your indexes would prefer. Always read the query, sanity-check the joins, and run it against a copy of your data or behind a LIMIT before using it in production. For destructive statements, double-check the WHERE clause before you ever execute it.