Six dialects
Pick the database you use so dialect-specific syntax and keywords are recognized.
Format messy SQL into readable, consistently indented queries for your database dialect
This tool is completely free — no credits required. All processing happens in your browser.
SELECT
o.id,
c.name,
sum(i.quantity * i.unit_price) AS total
FROM
orders o
JOIN customers c ON c.id = o.customer_id
LEFT JOIN order_items i ON i.order_id = o.id
WHERE
o.created_at >= '2026-01-01'
AND o.status IN ('paid', 'shipped')
GROUP BY
o.id,
c.name
HAVING
sum(i.quantity) > 2
ORDER BY
total DESC
LIMIT
20;Queries copied from logs, ORMs or a colleague's message often arrive as one long line. Formatting them puts each clause on its own line and indents the columns and conditions, so you can read, review and debug the query quickly.
The tool uses the open-source sql-formatter library, which parses your query before printing it.
The query is split into keywords, identifiers, strings, operators and comments using the rules of the dialect you pick, such as backtick identifiers in MySQL or square brackets in T-SQL.
Tokens are parsed into clauses (SELECT, FROM, WHERE, GROUP BY and so on). If the query can't be parsed, the formatter stops and reports where.
Each clause starts a new line, its contents are indented by your chosen width, and keywords are printed in the case you selected.
Pick the database you use so dialect-specific syntax and keywords are recognized.
Print SELECT and FROM in uppercase, lowercase, or exactly as written.
Match your team's style with 2 spaces, 4 spaces or tabs.
Unbalanced parentheses or unclosed strings are reported with their position.
Queries stay in your browser. Nothing is sent to a server or a database.
Anyone who reads or writes SQL.
Make ORM-generated or logged queries readable before optimizing them.
Tidy long reporting queries so joins and filters are easy to follow.
Format queries consistently so reviews focus on logic, not layout.
See how clauses nest and learn a clean, conventional SQL style.
If a valid query fails to parse, it may use dialect-specific syntax. Switch to the database you actually run it on.
Format two versions of a query the same way, then use the diff checker to see exactly what changed.
When a query must fit on one line, such as in a config value, use the SQL minifier on the formatted version.
Placeholders such as ?, $1 or :name format fine. Avoid pasting real customer values into any online tool.
Standard SQL, PostgreSQL, MySQL, SQLite, Google BigQuery and Microsoft T-SQL (SQL Server). Pick the one your query is written for.
No. Only whitespace and, if you choose, keyword case change. String literals, identifiers and comments are kept exactly as written.
The formatter couldn't understand part of the query, often an unclosed quote, a missing parenthesis or syntax from another dialect. The message gives the line and column to check.
Yes. Separate statements with semicolons and each one is formatted in turn.
No. It checks syntax only. It doesn't know your tables or columns, so a well-formatted query can still fail when you run it.
No. Formatting happens in your browser and nothing you paste is stored or uploaded.