SQL Formatter
Beautify SQL queries with configurable keyword casing, indentation, and clause line breaks.
About SQL Formatter
Long SQL queries squeezed onto one line hide their structure, and the difference between a correct and a buggy query is often just a misplaced join. This tool parses your SQL and lays each clause on its own line with nested subqueries indented, so the logical flow reads top to bottom.
Keyword casing is configurable between upper and lower, and string literals, comments, and quoted blocks are never touched regardless of their content. The parser handles common PostgreSQL, MySQL, and SQLite syntax, including window functions, CTEs, and dialect-specific keywords.
Backend developers formatting queries before code review, data analysts tidying long reports before sharing them, and DBAs documenting complex queries all benefit from a consistent, readable layout. It also helps when a messy query needs to be legible enough to debug in a ticket or a shared doc.
How to Use
- Paste your SQL query.
- Choose keyword casing (upper or lower).
- Copy the formatted query.
Example
select id,name from users where age>18 order by name; SELECT id, name FROM users WHERE age > 18 ORDER BY name;
Clauses move to their own lines and keywords are uppercased, making the query's structure readable at a glance.
FAQ
Which SQL dialects are supported?
Common syntax shared across PostgreSQL, MySQL, and SQLite, plus several dialect-specific keywords.
Does it handle subqueries?
Yes, subqueries are indented inside their parentheses so nesting stays clear.
Can it keep strings intact?
Yes, string literals and comments are left untouched regardless of their content.
Can it format a whole SQL script?
Yes. Statements separated by semicolons are each formatted independently and kept in order, so multi-statement scripts or migration files are handled as easily as a single query.
Are placeholder parameters preserved?
Yes. Question marks, named parameters like :id, and dollar placeholders are treated as tokens and preserved exactly, so prepared statements stay ready to execute.