SQL Beautifier: Format and Minify SQL Online for 20 Dialects
SQL Beautifier pretty-prints or minifies SQL with a token-aware pipeline built on sql-formatter. It covers 20 dialects, from PostgreSQL, MySQL and SQLite to SQL Server T-SQL, Oracle PL/SQL, BigQuery, Snowflake, DuckDB and ClickHouse. Strings, quoted identifiers, dollar-quoted function bodies and comments are never rewritten — only moved — and the result is re-tokenized and compared with the input. Review the formatted code, a statement list, a before/after diff and review hints in one place.
SQL Beautifier formats and minifies SQL entirely in the browser using sql-formatter. It supports the 20 dialects that sql-formatter provides: standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server T-SQL, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL, Trino, Hive, IBM Db2 and Db2 for i, DuckDB, ClickHouse, Couchbase N1QL, SingleStoreDB and TiDB. The list in the Dialect control is generated from the installed package, so it never offers a dialect the formatter cannot handle.
Formatting is lossless by construction. The input is tokenized first, and after sql-formatter runs, the output is tokenized again and compared with the original. String literals, quoted and bracketed identifiers, dollar-quoted bodies, E-strings and comments must survive unchanged; whitespace and the casing options you selected may change. If a construct cannot be formatted safely, the original text is returned with an explanation instead of a damaged query. Template tokens such as {{ value }}, {% if %} and ${name} are protected during formatting, T-SQL GO batches are formatted separately, and a script with several statements falls back statement by statement: the ones that parse are formatted and the rest are kept verbatim with line numbers.
The options cover the sql-formatter settings that change layout — indentation and tab width, tabular indent styles, keyword/function/data-type and unquoted-identifier casing, expression width, AND/OR line breaks, dense operators, semicolons on their own line, blank lines between statements, comment stripping with optional MySQL /*! */ and optimizer hints, line endings, a final newline and an optional trailing semicolon. A comma post-pass moves commas to a leading or trailing style without touching commas inside strings or comments. Placeholder recognition covers ?, ?1, :name, @name, $1, {{name}}, ${name} and %s so parameterised queries parse.
Beyond the formatted text, the tool lists every statement with its kind and line range, shows a line diff between input and output, and reports conservative review hints with jump-to-line links. A parameter preview can paste values over placeholders for reading only, with a warning that the result is not a safely quoted query. SQL can be extracted from string literals in several host languages and copied back as one, and the current settings can be exported as sql-formatter JSON, a .sqlfluff file, an .editorconfig section or a pg_format command.
The beautifier is useful to developers, DBAs and analysts who need to read, review, document or standardise SQL. Everything — including the syntax highlighting, diff, gzip size report and zip download — runs on your device; queries are not uploaded, and the page works offline once loaded.
Step 1: Paste or drop SQL into the input. A query snippet, a full migration script and T-SQL GO batches all work.
Step 2: Pick the dialect, or use the one-click suggestion when the tool recognises PostgreSQL, T-SQL, MySQL syntax and similar clues. You can also load a sample.
Step 3: Choose a preset or set keyword, function and data-type casing, indentation, expression width, comma style, comment handling, blank lines, line endings and placeholder styles under Advanced.
Step 4: Format, minify or both. Review the Code, Statements, Diff and Info & Issues tabs; the statements tab shows each statement's kind and line range, and issues are clickable to jump to the input line.
Step 5: Copy the result, download it, copy it as a JavaScript/Python/Java/C#/PHP/Go string literal, export matching sql-formatter, .sqlfluff or pg_format settings, or format a batch of files into a zip.
Use case: Make machine-generated SQL readable before a code review. Consistent indentation and casing let reviewers focus on the query instead of the layout.
Use case: Format a migration or ETL script statement by statement. If one statement cannot be parsed, the others are still formatted and the failing one is kept verbatim with its line number.
Use case: Compare a reformatted query with the original in the Diff tab before copying it anywhere. Only whitespace movement and the selected casing changes should appear.
Use case: Minify SQL for logs, fixtures or embedded queries while the token verification prevents strings and comments from being damaged.
Use case: Check a pasted query for common review hints such as UPDATE or DELETE without WHERE, JOIN without ON, = NULL, LIMIT without ORDER BY and OR 1=1.
Use case: Pull SQL out of a JavaScript template literal, Python triple-quoted string, Java text block, C# verbatim string, PHP heredoc or Go raw string, then format it and copy it back as the same kind of literal.
Use case: Make dialect mismatches visible. A statement the selected dialect cannot parse is reported with a line and column, and dialect detection can suggest the engine the SQL probably targets.
Use case: Standardise a folder of .sql files with the batch panel and download the formatted results as a zip, without uploading anything.