How to use SQL formatter
- 1
Paste your SQL
Paste a query or a whole script, or open a .sql file; Sample shows a messy query to try.
- 2
Choose the dialect
Pick your database so its quoting, operators and keywords are recognised correctly.
- 3
Set the style
Choose keyword case, indentation, comma position and layout to match your team’s conventions.
- 4
Format and copy
Press Format SQL or Minify, then copy the highlighted result or download it as .sql.
Limits and Pro
Free with no sign-up: 20 dialects, .sql files up to 10 MB, and scripts that format within 20 seconds; outputs over 600,000 characters are previewed in part and copied or downloaded in full.
Pro removes the ads; the formatter itself is the same on every plan. See Pro
About SQL formatter
Paste a one-line query from a log, an ORM's debug output or a colleague's chat message and this formatter lays it out the way a careful person would: one clause per line, selected columns and joins indented under their keyword, and subqueries nested so the structure is visible at a glance. It understands 20 SQL dialects — standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server T-SQL, SQLite, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Trino, DuckDB, ClickHouse, Hive, Db2, Db2 for i, SingleStore, TiDB and Couchbase N1QL — so dialect syntax such as backtick identifiers, square brackets, :: casts or dollar-quoted strings is kept intact.
You choose the house style: keywords in uppercase, lowercase or as written; function names and data types the same way; two spaces, four spaces or tabs; commas at the end or the start of lines; AND and OR before or after the line break; and a standard or tabular layout that lines keywords up in a column. Multi-statement scripts are separated by a blank line. Minify does the opposite, removing comments and extra whitespace while keeping strings, quoted names and optimizer hints untouched.
The output is syntax-highlighted and can be copied or downloaded as a .sql file. Formatting uses the open-source sql-formatter library, loaded the first time you press Format, and runs in a background worker so long scripts don't block the page.
The formatter changes only whitespace and letter case. It doesn't validate table or column names, run the query, or rewrite it for performance, and stored procedures with unusual vendor syntax may need the closest dialect.
Privacy
SQL is formatted inside your browser by a Web Worker, so queries containing table names, customer data or credentials are never sent to a server. Your dialect and style choices are saved in local storage; the SQL itself is not stored.
Features
20 SQL dialects
MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, Snowflake and 14 more.
Your house style
Keyword case, indentation, leading or trailing commas, AND/OR placement and tabular layout.
Minify too
Strip comments and whitespace for embedding SQL in code, keeping strings and hints intact.