Home/SQL Formatter
SQL

SQL Formatter

SQL formatting / minifying · supports multiple dialects

Dialect
Input SQLSQL
OutputSQL

Overview: SQL Formatter is an online tool for beautifying and minifying SQL statements. Powered by sql-formatter, it supports Standard SQL, MySQL, PostgreSQL, SQLite and Transact-SQL (MSSQL), turning messy queries into a consistent, readable style that is easy to review with the team.

How to use: Step 1 — paste the SQL you want to format on the left, or click "Sample" to load an example. Step 2 — pick the target dialect in the toolbar; different dialects handle keywords, functions and operators slightly differently. Step 3 — the tool formats the query live and shows the result on the right with keywords upper-cased and 2-space indentation. Step 4 — click "Minify" to collapse the SQL into a single compact line, handy for embedding in code or logs. Step 5 — copy or download the output as a .sql file.

Typical scenarios: DBAs format long queries to inspect execution plans when tracking slow SQL; developers polish ORM-generated SQL during optimisation; code reviewers normalise SQL to enforce a shared style; database export scripts are formatted before archiving; SQL extracted from log files is beautified for re-analysis.

Technical notes: Formatting is purely syntactic — it does not perform semantic validation and cannot guarantee that the SQL is valid. String literals (single-quoted content) are preserved unchanged. Keywords are upper-cased by default (configurable), while function names are kept as-is. It supports common DML/DDL such as SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, as well as WITH CTEs. Minify mode collapses all whitespace into a single space.

Privacy: SQL statements are processed entirely in your browser and never uploaded, so you can safely format queries that contain sensitive business information such as table names, columns or IP addresses.

Frequently Asked Questions

How do I use SQL Formatter?
Step 2 — pick the target dialect in the toolbar; different dialects handle keywords, functions and operators slightly differently. Step 3 — the tool formats the query live and shows the result on the right with keywords upper-cased and 2-space indentation.
What can SQL Formatter do?
Typical scenarios: DBAs format long queries to inspect execution plans when tracking slow SQL; developers polish ORM-generated SQL during optimisation; code reviewers normalise SQL to enforce a shared style; database export scripts are…
Is my data private when I use SQL Formatter?
Privacy: SQL statements are processed entirely in your browser and never uploaded, so you can safely format queries that contain sensitive business information such as table names, columns or IP addresses. Privacy: SQL statements are processed entirely in your browser and never uploaded, so you can safely format…
What technical details should I know about SQL Formatter?
String literals (single-quoted content) are preserved unchanged. Keywords are upper-cased by default (configurable), while function names are kept as-is.