SQL Formatter — Format and Beautify SQL Queries
Format and beautify SQL queries with customisable indentation, keyword casing, and dialect support — in your browser, no upload.
SQL Formatter
Format and beautify SQL queries. Works entirely in your browser — no uploads.
SQL is the universal query language, and unformatted SQL is the universal code-review complaint. A multi-table join with subqueries, window functions, and a CTE can span thirty lines with no whitespace convention and a mix of UPPER, lower, and Mixed keyword casing. A formatter solves the mechanical part of the problem: it parses the SQL, identifies keywords, identifiers, literals, and operators, and rewrites the text with consistent indentation, line breaks, and casing. The formatted output is the same query — the database executes it identically — but it is readable, diff-friendly, and paste-compatible with style guides. The formatter runs in your browser, which means your SQL never leaves your device — useful when the query contains table names, column names, or join conditions that reveal business logic.
How to use
Paste your SQL
Paste a SQL query, a script, or a DDL statement. The formatter parses the SQL and rewrites it with consistent indentation, line breaks, and keyword casing.
Choose formatting options
Pick indentation width, keyword case (upper/lower/capitalise), comma position (leading/trailing), and dialect hints (PostgreSQL, MySQL, SQLite, T-SQL, Standard SQL).
Copy the formatted SQL
Copy the formatted output to your clipboard. The formatter preserves comments, string literals, and query structure — only whitespace and keyword case change.
Frequently asked
Does it support specific SQL dialects?
The formatter has dialect hints for PostgreSQL, MySQL, SQLite, Microsoft T-SQL, and Standard SQL. The dialect affects keyword recognition and function-name casing but does not validate syntax — that's the role of a parser, not a formatter.
Will the formatter change my query's meaning?
No. The formatter changes only whitespace and keyword casing. String literals, identifiers, numbers, and operators are preserved exactly. Comments are left untouched. A query before and after formatting produces the same query plan on any database.
How are subqueries and CTEs indented?
Subqueries are indented one level deeper than their parent. CTEs (WITH clauses) are formatted with the CTE name on one line and the body indented. Nested CTEs and deeply nested subqueries are indented at their nesting depth.
Can it format DDL statements?
Yes. CREATE TABLE, ALTER TABLE, CREATE INDEX, and other DDL statements are formatted with schema objects aligned. Column definitions in CREATE TABLE are indented under the table name.
Limitations
- No syntax validationThe formatter rewrites whitespace and keyword case. It does not check whether the SQL is valid or whether the objects referenced exist. Invalid SQL is formatted without error — the output may still not run.
- No query optimisationThe output is syntactically identical to the input except for whitespace and casing. The formatter does not rewrite queries for performance.
- Stored procedure bodies not reformattedThe body of CREATE PROCEDURE, CREATE FUNCTION, and anonymous blocks is treated as a string literal and left unchanged. The outer DDL structure is formatted.
Platform notes
- macOS
- The browser tool is the right pick for one-off formatting of SQL pasted from a terminal, a log file, or a code review comment.
- Web
- Runs client-side. The SQL you paste stays local.