SQL Formatter
Beautify SQL queries with consistent indentation and UPPERCASE keywords — runs entirely in your browser.
Standard SQL
Drop a .sql file here to load it
Ctrl + Enter to format
SQL formatting conventions
This formatter applies the most common SQL style conventions:
- Keywords in UPPERCASE —
SELECT,FROM,WHERE,JOIN, etc. Distinguishes reserved words from identifiers and table/column names. - Major clauses on new lines —
SELECT,FROM,WHERE,GROUP BY,ORDER BY,HAVING,LIMITeach start on their own line. - JOIN conditions indented —
ONclauses are indented under the JOIN keyword. - Subqueries indented — nested SELECTs are indented inside parentheses.
Why SQL formatting matters
Production SQL queries are often written in tight windows, copied from ORMs, or extracted from query logs — all of which produce minified, hard-to-read SQL. Formatting is the first step before:
- Code review of database migrations.
- Debugging a slow query by finding which subquery or JOIN needs an index.
- Documenting complex queries in technical specs.
- Converting raw query logs into readable queries for analysis.