What is the SQL Formatter?
Queries copied from logs, ORMs or old code often arrive as one very long line. This SQL formatter rewrites them in a clear, consistent layout. Every main clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY…) starts its own line. Columns and conditions are indented below their clause, JOINs and their ON conditions are aligned, and subqueries are indented as nested blocks.
The formatter reads SQL as tokens rather than plain text. String literals, quoted identifiers and comments are never changed, and the AND inside BETWEEN … AND … stays on one line. It works with standard SQL as used by MySQL, PostgreSQL, SQL Server, SQLite, Oracle and BigQuery. Minify does the opposite: it removes comments and line breaks so a query fits on a single line, for example in a config file or log message.
How to use the SQL Formatter
- Paste one or more SQL statements into the box. Separate statements with semicolons.
- Choose the indentation and whether keywords should be uppercased.
- Click Format to beautify or Minify to compress, then copy or download the result.
Frequently asked questions
Does the formatter change what my query does?
No. Only whitespace and the case of SQL keywords change. Table names, column names, string values and comments are kept exactly as you wrote them.
Which SQL dialects are supported?
Standard SQL syntax shared by MySQL, MariaDB, PostgreSQL, SQL Server, SQLite, Oracle and BigQuery, including backtick, double-quote and bracket identifiers. Dialect-specific procedural code (PL/pgSQL, T-SQL blocks) is formatted on a best-effort basis.
Is my SQL uploaded?
No. Formatting runs in your browser, so queries containing real table names or data stay on your machine.
Should SQL keywords be uppercase?
SQL keywords are not case-sensitive, so it is a style choice. Uppercase keywords are the most common convention because they make the query structure stand out from table and column names.