SQL Formatter
Pretty-print SQL queries. Supports MySQL, PostgreSQL, SQLite, MS SQL, BigQuery, and more.
About SQL Formatter
Pretty-print long single-line SQL into clean, indented, multi-line form. Great for code review, debugging, and documentation.
Supported Dialects
Standard SQL, MySQL, PostgreSQL, SQLite, MS SQL (T-SQL), BigQuery and more - keywords and functions of each dialect are recognized correctly.
Privacy
All processing happens in your browser. You can safely format production-DB queries and sensitive SQL.
Dialect-specific differences to watch out for
- LIMIT vs TOP vs FETCH - MySQL and PostgreSQL use
LIMIT 10; SQL Server usesSELECT TOP 10; Oracle and standard SQL useFETCH FIRST 10 ROWS ONLY. This is a common source of bugs when migrating between databases. - String concatenation - The standard is
||; MySQL usesCONCAT(); SQL Server uses+. In MySQL,||is interpreted as OR, so relying on it produces completely wrong results. - Date functions -
NOW()in MySQL,CURRENT_TIMESTAMPin standard SQL,GETDATE()in SQL Server,CURRENT_DATETIME()in BigQuery. Always replace these when porting a query. - Identifier quoting - MySQL uses backticks (
`column`); standard SQL and PostgreSQL use double quotes ("column"); SQL Server uses brackets ([column]). Case-sensitivity rules differ as well. - Boolean - PostgreSQL has a native
BOOLEANtype; MySQL emulates it withTINYINT(1); Oracle usesNUMBER(1). - RETURNING clause - PostgreSQL, SQLite 3.35+, and MariaDB support
INSERT ... RETURNING *. MySQL 8 does not; SQL Server usesOUTPUTinstead.
SQL anti-patterns - five you see all the time
- SELECT * - In production, always name the columns you actually need. Wildcards make schema changes risky and waste network bandwidth.
- Wrapping a column in a function inside WHERE -
WHERE DATE(created_at) = '2026-05-05'prevents index use. Rewrite as a range:WHERE created_at >= '2026-05-05' AND created_at < '2026-04-21'. - N+1 queries - Running a query inside a loop. Consolidate with a JOIN or an IN clause instead.
- Implicit type coercion -
WHERE phone = 01012345678(integer) vs'01012345678'(string). A type mismatch disables the index and can produce locale-dependent results. - ORDER BY RAND() - Triggers a full table scan. On large tables use a sampling subquery or, in BigQuery, TABLESAMPLE.
Official references
- PostgreSQL SQL Commands - The official reference for the dialect closest to the SQL standard.
- MySQL Reference Manual - Full function and syntax documentation.
- BigQuery Standard SQL - Data warehouse dialect reference.
- T-SQL Reference (SQL Server) - Covers TOP, IDENTITY, OUTPUT, and other Microsoft extensions.
- SQLite SQL Syntax - Lightweight embedded database syntax reference.
- sql-formatter (open source) - The library powering this formatter.
When your queries return JSON columns, use the JSON Formatter & Converter to inspect the output. For HTML, CSS, or JS code formatting, see the HTMLㆍCSSㆍJS Formatter.
FAQ
Does it format stored procedures and triggers?
Basic DDL/DML and some procedural SQL are supported. Very complex PL/SQL or T-SQL blocks may have edge cases.
Is the output executable?
Yes. Formatting only changes visual layout - the SQL semantics are preserved.
Which SQL dialects are supported?
Besides standard SQL, major dialects are recognized: MySQL, PostgreSQL, Oracle PL/SQL, SQL Server T-SQL, and BigQuery. Dialect-specific functions may be parsed as generic identifiers.