SQL Formatter
Paste any SQL query and format it with consistent indentation and keyword casing. Supports common SQL dialects.
SQL dialects vary widely. This tool aims for readable, consistent formatting but does not guarantee perfect support for every SQL dialect or vendor-specific syntax.
How to Use
- 1Paste your SQL query into the input box.
- 2Choose a dialect if you want dialect-aware keyword handling.
- 3Click Format for readable output, or Minify to collapse it to one line.
Features
- Consistent indentation and keyword casing
- Support for common SQL dialects
- One-click minify
- Copy the formatted result
Example
Click Load Example to format a sample query with a join, filter, and order by clause.
About This Tool
SQL formatting makes long or nested queries easier to read by aligning clauses like SELECT, FROM, WHERE, and JOIN on their own lines with consistent indentation. This is especially useful when reviewing queries in a code review or debugging a slow query plan.
SQL is not a single standardized language: vendors like PostgreSQL, MySQL, and SQL Server each support slightly different syntax. This tool formats common SQL constructs well but does not claim perfect support for every dialect-specific feature.
FAQ
- Which SQL dialects are supported?
- Standard SQL, MySQL, PostgreSQL, SQLite, MariaDB, and SQL Server (T-SQL) are available from the dialect selector.
- Will this tool execute my query?
- No. This tool only reformats the text of your query; it never connects to a database or executes anything.