Sql Formatter
Poorly formatted SQL is hard to read and debug. Our SQL formatter applies consistent indentation, keyword capitalization, and line breaks to make any SQL query — from simple SELECTs to complex multi-join CTEs — immediately readable. It also supports multiple dialects: MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.
Input SQL
Formatted
About the SQL Formatter & Beautifier
Poorly formatted SQL is hard to read and debug. Our SQL formatter applies consistent indentation, keyword capitalization, and line breaks to make any SQL query — from simple SELECTs to complex multi-join CTEs — immediately readable. It also supports multiple dialects: MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.
How to use it
- Paste any SQL query (minified or poorly formatted).
- Select your SQL dialect for dialect-specific keyword handling.
- Choose formatting options: indentation size, keyword case (UPPER/lower), line break style.
- See formatted output — copy or download as .sql file.
Formula & methodology
No mathematical formula — SQL formatting follows convention: keywords UPPERCASE; identifiers lowercase; each clause (SELECT, FROM, WHERE, JOIN, GROUP BY) on its own line; joined conditions aligned; subqueries indented one level. CTEs formatted with WITH clause on its own line, each CTE separately indented.
Common use cases
- Making auto-generated ORM queries readable for debugging
- Code review: ensuring SQL in stored procedures follows team standards
- Documentation: formatting queries before including in technical docs
- Database administration: reading execution plans with formatted queries
- Legacy code: reformatting decades-old stored procedures for maintainability
Frequently asked questions
Related tools
All Tools →Embed this tool on your site
Free for personal and commercial use. Just copy the snippet below.