SQL Formatter
Format and beautify SQL queries.
- Runs in your browser
- No signup
How to use SQL Formatter
Paste your SQL
Queries from logs, ORMs or colleagues, however they are formatted.
Choose a dialect
Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, BigQuery or Transact-SQL. Optionally uppercase keywords.
Format or minify
Get neatly indented SQL with syntax highlighting, or a compact single line.
How to format SQL queries
Long SQL queries copied from logs or generated by ORMs are hard to read and harder to debug. SQL Formatter lays them out with consistent indentation and line breaks, so joins, conditions and subqueries are easy to follow. It formats in your browser and never touches your database.
Dialects
Pick the dialect you use so dialect-specific syntax is handled properly: Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, BigQuery or Transact-SQL (SQL Server). Backtick identifiers, bracketed names and dialect keywords are recognized.
Readable SQL conventions
Formatting follows habits most teams share:
- Each major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY) starts on its own line.
- Selected columns and conditions are indented under their clause.
- Keywords can be uppercased to stand out from table and column names.
- Subqueries are indented so their scope is clear.
Formatting is safe
Only whitespace, and optionally keyword case, changes. The logic of the query and its results stay exactly the same. Minify mode strips comments and collapses the query onto one line for embedding in code or config. Queries often contain table names and data values, so everything is processed locally.
Readable SQL is easier to review
Consistent formatting makes code review faster, reveals missing join conditions and misplaced parentheses, and produces cleaner diffs in version control. Many teams format queries before committing them, the same way they format application code.