Developer tool · runs in your browser
SQL formatter online: paste a query, get it indented
Paste SQL into the box and pick PostgreSQL, MySQL, SQL Server or SQLite. The formatted query appears below the input as you type, ready to copy or download as a .sql file.
- Keyword case: UPPERCASE, lowercase or as typed
- Indent with 2, 4 or 8 spaces or a tab
- Expand and indent, or minify to one line
- Strings and comments are left exactly as written
Formatted SQL
Updates as you typeWhat the formatter read
What you get
Indented, re-cased SQL
Each clause starts on its own line. Joins, filters, CASE blocks, CTEs and nested subqueries are indented so you can scan them separately.
Strings stay untouched
The query is split into tokens first. Quoted strings, quoted identifiers and comments are never re-cased or broken across lines.
A one-line version
Minify collapses whitespace and removes comments, because a line comment would otherwise swallow the rest of a one-line query.
Checks while you type
An unclosed string, quoted identifier or block comment is reported, and unbalanced parentheses show as a warning under the result.
Formatting SQL so each clause is easy to read
Why the dialect matters
Quoting rules differ between engines. PostgreSQL uses double quotes for identifiers and dollar-quoted blocks for function bodies. MySQL adds backticks, a backslash escape inside strings and # line comments. SQL Server wraps identifiers in square brackets. SQLite accepts all three. The dialect you pick changes how the tokeniser reads these characters, so an identifier or string that contains one of them is kept intact.
What changes and what does not
Only line breaks, indentation and the case of real keywords change. Table names, column names, string values and comments stay as you wrote them, and nothing is reordered or optimized. The query is never executed or validated, so a formatted query is not proof that it will run.
Limits
This is a formatter, not a grammar-based parser. It follows clause keywords, commas, parentheses and CASE blocks, which covers ordinary queries. Procedural code such as PL/pgSQL bodies, T-SQL control flow or stored procedure definitions is laid out by the same general rules and may not match your house style.
Questions before you run it
Which SQL dialects are supported?
PostgreSQL, MySQL / MariaDB, SQL Server (T-SQL) and SQLite. The dialect sets how identifiers, strings and comments are recognised, for example backticks in MySQL or square brackets in SQL Server.
Does formatting change the meaning of my query?
No. Expanded output only changes line breaks, indentation and keyword case. Strings, identifiers and comments are kept as written, and nothing is rewritten or reordered. Minify also removes comments.
Can I format stored procedures and DDL statements?
CREATE, ALTER, INSERT, UPDATE, DELETE and CTEs are laid out clause by clause, and scripts with several statements separated by semicolons are formatted in sequence. Procedural blocks such as stored procedure bodies follow the same general rules and may not match your database's usual style.
What does the minify option do?
Minify removes comments and collapses whitespace into a single-line query. This is useful when embedding SQL in application code or configuration files. Keep the expanded output if the comments matter to you.
Is my SQL sent to a server?
No. All formatting runs in your browser using JavaScript. Your queries never leave your device.