SQL Formatter
Paste a query, get it back with clean indentation, one clause per line, and (optionally) uppercase keywords.
How it works
The formatter tokenizes your SQL — recognizing strings, quoted identifiers, comments, numbers and keywords — then rebuilds it with a consistent style: major clauses (SELECT,FROM, WHERE, joins,GROUP BY, ORDER BY, …) start on their own lines, AND/OR conditions are indented, and subqueries inside parentheses get their own indent level.
Strings and comments are never touched, so'a b -- not a comment' stays exactly as written. The formatter is syntax-aware but not a full parser: if the SQL is malformed it still formats what it can and flags unbalanced parentheses.
Frequently asked questions
Which SQL dialects are supported?
The formatting is ANSI-style and works for MySQL, PostgreSQL, SQLite, SQL Server, BigQuery and most other dialects. Dialect specifics like T-SQL’s TOP or backtick identifiers are handled as ordinary tokens.
Will it break my strings or comments?
No. Single-quoted strings (including escaped''), double-quoted and backtick identifiers, and both -- and /* */ comments are treated as opaque blocks.
Does it validate the SQL?
It checks that parentheses balance and flags it if they don’t, but it doesn’t run a full grammar check — use your database client for validation.
Can I format multiple statements?
Yes. Separate statements with semicolons and each one gets formatted and separated by a blank line.

