SQL Formatter & Validator — Prettier for SQL.
Paste a query, pick a dialect, get clean SQL — formatted live as you type, with syntax errors and misspelled keywords flagged inline. SELCT → did you mean SELECT?
select u.id, u.name, count(o.id) as order_count, sum(o.total) as lifetime_value from users u left join orders o on o.user_id = u.id where u.created_at >= '2026-01-01' and u.status in ('active', 'trial') group by u.id, u.name having count(o.id) > 0 order by lifetime_value desc limit 25;SELECT
u.id,
u.name,
count(o.id) AS order_count,
sum(o.total) AS lifetime_value
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.created_at >= '2026-01-01'
AND u.status IN ('active', 'trial')
GROUP BY
u.id,
u.name
HAVING
count(o.id) > 0
ORDER BY
lifetime_value DESC
LIMIT
25;Syntax looks valid — no misspelled keywords or anti-patterns found.
Format
Consistent, readable SQL with your conventions — keyword case, indent, comma style, line width.
Validate
Real parsing per dialect. Syntax errors point at the exact line and column, never a vague failure.
Suggest
A spell-checker for SQL: SELCT → SELECT, COUTN( → COUNT(. Typos surface before your database sees them.
API
A REST endpoint for Pro subscribers: POST SQL, get back formatted output, syntax errors, and typo warnings as JSON.
A SQL formatter and validator that runs in your browser
sqlfmtis a free online SQL formatter and validator — think “Prettier for SQL, plus a spell-checker.” Paste a query, pick your dialect, and get clean, consistently styled SQL with syntax errors and misspelled keywords flagged inline. There’s no setup, no extension to install, and no account required to start.
Everything runs client-side, so your queries stay on your machine. That makes sqlfmt safe to use on work schemas and proprietary SQL: the analysis happens in the page itself, and your SQL is only sent anywhere if you deliberately save or share a snippet.
Every dialect, parsed for real
Most online formatters apply one generic style and guess at errors with pattern-matching. sqlfmt parses each query against the real grammar of the dialect you choose, so dialect-specific syntax is understood instead of mistaken for a mistake.
- PostgreSQL — Dollar-quoted strings, JSONB operators, and Postgres-only syntax parsed natively.
- MySQL — Backtick identifiers and MySQL's procedural extensions handled without false errors.
- SQLite — The lightweight dialect that powers mobile and embedded apps.
- SQL Server (T-SQL) — Bracketed identifiers, TOP, and T-SQL control-of-flow keywords recognised.
- BigQuery — Standard SQL with arrays, structs, and backtick-quoted table paths.
REST API for automations and pipelines
Pro subscribers can call the sqlfmt engine from any language or tool via a simple HTTP endpoint. One POST request returns the full analysis — formatted SQL, syntax errors with line and column, and typo warnings with ranked suggestions — as a single JSON response.
POST /api/v1/analyze
Authorization: Bearer <your-api-key>
Content-Type: application/json
{ "sql": "SELCT * FROM users", "options": { "dialect": "postgresql" } }
→ 200 OK
{
"formatted": "SELECT *\nFROM users",
"formatError": null,
"syntaxErrors": [],
"typoWarnings": [
{ "word": "SELCT", "suggestions": ["SELECT"], "line": 1, "column": 1 }
]
}API keys are generated from your account page and are scoped to your Pro subscription. Keys are shown once at creation and stored only as a hash — rotate anytime without losing access. The endpoint is rate-limited to 60 requests per minute per key.
Why format SQL?
Consistent formatting makes SQL faster to read, easier to review, and cleaner to diff in version control. A shared style ends arguments over keyword case and indentation, and a quick validation pass catches syntax errors and typos at write time — long before a query fails in production or burns a slow round-trip to the database.
Frequently asked questions
- Is sqlfmt free to use?
- Yes. Formatting and validation are free, with no account required — anonymous users get a small daily allowance, and a free account raises the limit. A Pro plan adds unlimited analyses, every dialect, saved snippets, live formatting as you type, and REST API access.
- Does my SQL get uploaded to a server?
- No. Formatting, validation, and typo-checking all run locally in your browser. Your SQL only leaves the page if you choose to save a snippet or create a shareable link while signed in.
- Which SQL dialects does sqlfmt support?
- Five: PostgreSQL, MySQL, SQLite, SQL Server (T-SQL), and BigQuery. Each query is parsed with that dialect's real grammar, so dialect-specific syntax doesn't get flagged as an error.
- What's the difference between formatting and validation?
- Formatting rewrites your SQL into a consistent style — keyword case, indentation, comma placement, and line width. Validation parses the query to catch syntax errors with an exact line and column, and a spell-checker flags misspelled keywords like SELCT or COUTN before your database ever sees them.
- Does sqlfmt have a public API?
- Yes. Pro subscribers can access POST /api/v1/analyze with a Bearer API key generated from the account page. Send a JSON body with a "sql" string and an optional "options.dialect" field; the response is a JSON object with "formatted" (the clean SQL), "syntaxErrors" (each with line, column, and a snippet), and "typoWarnings" (each with the misspelled word and ranked suggestions). SQL findings always return HTTP 200 — 4xx is reserved for bad requests, missing auth, or exceeding the 60-requests-per-minute rate limit.
Ready to clean up a query? Scroll back up to the editor, or read the sqlfmt blog for fixes to common SQL errors across every dialect.