Format or minify SQL in your browser for PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, SQLite, Oracle and 12 more dialects. Choose spaces or tabs and upper, lower or preserved keyword case. Minify keeps string literals intact and turns -- comments into /* */ so the one-line query still runs.
A SQL formatter (or SQL beautifier) rewrites a query so each clause starts on its own line and nested parts are indented, which makes long queries much easier to read, review and debug. This tool uses the sql-formatter library and understands the syntax of 19 SQL dialects. It can also do the opposite and compress a query onto one line.
.sql file onto it.format.sql with the buttons in the editor corner.select / SELECT to upper or lower case-- line comments to /* */ block comments so nothing after them is commented outInput:
Output (PostgreSQL, 2 spaces, Upper):
Either the SQL has a syntax error, or it uses syntax that the selected Language does not support (for example PostgreSQL-style ::int casts with MySQL, or [bracketed] identifiers with Standard SQL). Try choosing the dialect of the database the query was written for.
No. Only whitespace, line breaks and (if you choose Upper or Lower) the case of keywords change. Table names, column names and string values are not modified.
No. Formatting and minifying run in your browser, so it is safe to paste queries that contain internal table names.