SQL Formatter
Keyword case
SELECT o.id, o.customer_id, c.name, sum(oi.quantity * oi.unit_price) AS total FROM orders o JOIN customers c ON c.id = o.customer_id JOIN order_items oi ON oi.order_id = o.id WHERE o.status = 'completed' AND o.created_at >= '2026-01-01' GROUP BY o.id, o.customer_id, c.name HAVING sum(oi.quantity * oi.unit_price) > 100 ORDER BY total DESC LIMIT 20;
Turn a dense, single-line SQL query into a readable, consistently indented statement. Choose the dialect that matches your database (MySQL, PostgreSQL, or SQL Server), pick upper or lower case for keywords, and adjust the indent style to match your team's conventions.
Frequently asked questions
Why does dialect matter for formatting?
Different databases have dialect-specific syntax — SQL Server's TOP clause, PostgreSQL's array literals, MySQL's backtick identifiers — and the formatter needs to know the dialect to parse and indent these correctly.
What's the difference between the indent styles?
Standard indents each clause on its own line. Tabular styles align column lists and conditions into a grid, which some teams prefer for wide SELECT statements with many columns.
Will formatting change what my query does?
No — formatting only affects whitespace and keyword casing. The query's logic and behavior remain identical.