Free online SQL formatter and beautifier
Paste a messy query and get clean, consistently indented SQL in one click. The formatter supports PostgreSQL, MySQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and more, runs in your browser, and never uploads your queries.
What the SQL formatter does
- Beautify: puts each clause on its own line, indents joins, subqueries and conditions, and aligns column lists so long queries are easy to review.
- Minify: collapses a query onto one line and removes comments (optimizer hints are kept), handy for config files, logs and URLs.
- Keyword case and indent: choose UPPERCASE or lowercase keywords and 2 spaces, 4 spaces or tabs to match your team's style guide.
- Dialect aware: pick your database so vendor-specific operators, quoting and functions are recognised instead of being mangled.
Is it safe to paste production queries?
Yes. Formatting happens entirely in your browser. Your SQL is not sent to a server, stored or logged, and the tool only changes whitespace and keyword case. It never connects to a database or executes anything.
Frequently asked questions
Does formatting change what my query does?
No. Only whitespace and keyword capitalisation change. String literals, identifiers and comments are left as written. Always run your tests if you paste formatted SQL into code.
Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, IBM Db2, Apache Spark, Hive, Trino, ClickHouse and DuckDB.
Why did I get a parse error?
Usually an unterminated string or quote, or syntax from a different dialect. Check the quotes and select the dialect that matches your database.
Can I format several statements at once?
Yes. Separate statements with semicolons and each is formatted with a blank line between them.