SQL Builder

Build a SQL query from fields or from plain text — for 9 dialects.

SELECT · INSERT · UPDATE · DELETE JOIN · WHERE · GROUP BY ORDER BY · LIMIT · subqueries MySQL · PostgreSQL · …
BuilderAssemble the query from fields — runs entirely in the browser
Action
Dialect
Table
Columns (comma-separated; * for all)
Values (in column order)
New values (SET)
Join other tables (JOIN)
Conditions (WHERE)
Group by (GROUP BY)
After grouping (HAVING)
Sort (ORDER BY)
Max rows (LIMIT)
Skip rows (OFFSET)
Generated query

      
Text values are quoted automatically; numbers, NULL, TRUE/FALSE and function calls are left as-is. Review the query before running it against a real database.
REST API — for developers

Open API — no account, username or password. JSON in and out, CORS enabled (Access-Control-Allow-Origin: *), so it is callable from anywhere.

Endpoints

GET  /api/healthservice info and the list of endpoints
GET  /api/dialectssupported SQL dialects
POST /api/sqlgenerate SQL from plain text (uses the Anthropic API)

POST /api/sql — request body

{
  "request": "top 10 customers by revenue in 2024, with email",   // required
  "dialect": "PostgreSQL",   // optional, default "MySQL"
  "schema":  "customers(id, name, email), orders(id, customer_id, total)",  // optional
  "readOnly": false,         // optional — SELECT only
  "explain":  false          // optional — explanation in "notes"
}

Response 200

{
  "sql": "SELECT ...",
  "notes": "assumptions or warnings, may be empty",
  "dialect": "PostgreSQL",
  "model": "claude-opus-5",
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 99, "output_tokens": 296 }
}

Errors return { "error": "..." } with status 400 / 401 / 405 / 422 / 429 / 5xx.

Example

curl -X POST /api/sql \
  -H "Content-Type: application/json" \
  -d '{"request":"count customers by country","dialect":"MySQL"}'

Protection (optional)

The API is open by default. In the server's .env you can enable RATE_LIMIT_PER_MIN (requests/minute per IP, default 20) and API_TOKEN (requires Authorization: Bearer <token> or X-Api-Key for POST /api/sql).

Full documentation: README on GitHub.