SQL Formatter & Beautifier Online
Options
How This SQL Formatter Works
Queries copied out of ORM logs, slow-query monitors, or APM traces almost always land on a single line. When four LEFT JOIN clauses, a subquery, and a CASE statement are crammed together, finding a missing join condition or a bad filter takes way longer than it should.
You can format SQL online across 12 database dialects (including PostgreSQL, MySQL, T-SQL, PL/SQL, BigQuery, and Snowflake) right in your browser. The parser follows engine-specific syntax rules from the PostgreSQL SQL syntax documentation and the MySQL statement reference, so operators like :: type casts, backtick-quoted identifiers, and $1 bind parameters stay intact.
The SQL beautifier also adapts to your team's style guide with one click. Data engineering teams using dbt often switch to Commas before for cleaner Git diffs, while DBAs often prefer Right aligned keywords to create a vertical river of whitespace. When you need the reverse and want to pack a multi-line query into a JSON string or shell script, Collapsed mode works as a one-click SQL minifier. And if you are putting together INSERT or WHERE test queries that need sample primary keys, you can generate or inspect them with our UUID generator and decoder.
Comparing SQL Formatting & Indentation Styles
Default (Trailing Commas)
StandardPlaces top-level clauses flush left and indents column expressions with commas at the end of each line.
SELECT u.id, u.email, COUNT(o.id) AS total_orders FROM users u WHERE u.active = true;
Commas before (Leading Commas)
Data Engineering / dbtPlaces commas at the start of each new column line so commenting out the last column never breaks syntax.
SELECT u.id , u.email , COUNT(o.id) AS total_orders FROM users u WHERE u.active = true;
Right aligned (River Style)
Visual ScanningAligns SQL keywords along a vertical margin so clauses and table expressions form two distinct columns.
SELECT u.id,
u.email,
COUNT(o.id) AS total_orders
FROM users u
WHERE u.active = true;Collapsed (Minified One-Line)
SQL MinifierStrips comments and collapses line breaks into a compact string ready for logs, CLI flags, or JSON payloads.
SELECT u.id, u.email, COUNT(o.id) AS total_orders FROM users u WHERE u.active = true;
Supported SQL Dialects & Formatting Rules
How the SQL query formatter handles identifier quoting, bind parameters, and special operators across supported database engines.
| SQL Dialect | Identifier Quoting | Parameter Syntax | Dialect-Specific Syntax Supported |
|---|---|---|---|
| PostgreSQL | Double quotes ("table") | $1, $2, :param | :: type casting, JSONB operators (->, ->>), CTEs (WITH), ILIKE |
| MySQL & MariaDB | Backticks (`table`) | ?, :name | ON DUPLICATE KEY UPDATE, LIMIT / OFFSET, # single-line comments |
| T-SQL (SQL Server) | Square brackets ([table]) | @variable | TOP (n), CROSS APPLY, GO batch separators, ISNULL() |
| PL/SQL (Oracle) | Double quotes ("TABLE") | :bind_var | BEGIN...END blocks, := assignments, NVL, CONNECT BY |
| Google BigQuery | Backticks (`proj.ds.tbl`) | @param, ? | STRUCT and ARRAY literals, UNNEST(), QUALIFY, Window frames |
| Snowflake | Double quotes ("TABLE") | :1, ?, $var | QUALIFY clause, FLATTEN, semi-structured : path traversal |
| SQLite | Double quotes or backticks | ?, :name, @name | ON CONFLICT DO UPDATE upserts, PRAGMA statements |
| Redshift & Spark SQL | Double quotes / Backticks | $1, :param, ? | DISTKEY, SORTKEY, LATERAL VIEW EXPLODE, Delta commands |