A SQL formatter rewrites a query so its structure is visible: SELECT, FROM, WHERE, GROUP BY and ORDER BY each start a new line, columns and conditions are listed one per line, and subqueries are indented. Paste your SQL, choose keyword case and indent, and copy the readable result. The query itself is not changed or run.
How to use the SQL Formatter
- Paste your SQLPaste one or more statements. Separate statements with semicolons.
- Choose the stylePick uppercase or lowercase keywords, or leave them as typed, and set the indent.
- Copy or downloadCopy the formatted query or download it as a .sql file.
How the SQL formatter lays out a query
Queries copied from application logs or an ORM usually arrive as one long line. This SQL formatter breaks them up using a few consistent rules:
- Main clauses (
SELECT,FROM,WHERE,GROUP BY,HAVING,ORDER BY,VALUES,SET) start a new line, with their contents indented underneath. - Lists are split one item per line after each comma, so selected columns are easy to scan and to diff.
- Joins each get their own line under
FROM, with theONcondition beside them. ANDandORstart a new line, except inside parentheses and inBETWEEN x AND y.- Subqueries in parentheses are indented one level deeper; function calls such as
COUNT(*)stay on one line. CASEexpressions put eachWHENandELSEon its own line.CREATE TABLElists one column definition per line.
String literals, quoted identifiers and comments are never altered. Keyword case applies to reserved words only; table, column and function names keep the case you typed.
Dialects and limits
The formatter works on tokens rather than on a full grammar, so it is not tied to one database. It understands the quoting and operators of the common dialects: "double quoted" identifiers, MySQL backticks, SQL Server [brackets], PostgreSQL :: casts and JSON operators, and placeholders such as ?, :name, $1 and @var. Comments in both -- and /* */ form are preserved.
Because it does not parse the full language, it cannot tell you that a query is wrong. It will format a statement with a missing comma or a misspelled keyword without complaint. Stored procedures and vendor-specific scripting are formatted on a best-effort basis and may need a manual touch.
Nothing is sent to a database or a server: formatting happens in your browser, which matters when a query contains customer data or internal table names. To compare two versions of a query after formatting, use the text diff checker.
Frequently asked questions
How do I format a SQL query online?
Paste the query into the SQL formatter, choose the keyword case and indent, and copy the result. Each clause starts on a new line and lists are split one item per line.
Which SQL dialects are supported?
It works with standard SQL and the common syntax of MySQL, PostgreSQL, SQLite, SQL Server and Oracle. Dialect-specific procedural code is formatted on a best-effort basis.
Does it change my query?
No. Only whitespace and, if you choose, the case of reserved keywords change. Strings, identifiers, comments and the logic stay exactly as written.
Does it check my SQL for errors?
No. It is a formatter, not a validator, and it does not connect to any database.
Is my query uploaded?
No. The query is formatted locally in your browser.
Last updated 24 November 2026 by the TheTechFolk team.