Why format SQL?
Consistent indentation and keyword casing make SQL queries far easier to read, review, and debug β especially long queries with multiple joins, subqueries, or conditions. A formatter removes the need to manually align clauses.
How to use this tool
Paste your SQL query, choose the dialect that matches your database (Standard SQL, MySQL, PostgreSQL, SQL Server, or SQLite), and click Format. The formatted result appears below, ready to copy. Dialect-specific syntax such as PostgreSQL's ::type casts or SQL Server's TOP clause is handled correctly.
The Keyword case option controls how SQL keywords such as SELECT, LEFT JOIN and GROUP BY are written: UPPERCASE (the default) or lowercase. Table names, column names and function calls like count() keep the casing you typed.
Example
This single-line query with a join, filter, grouping and sort:
select u.id,u.name,count(o.id) as order_count from users u left join orders o on u.id=o.user_id where u.active=1 and o.created_at>='2026-01-01' group by u.id,u.name order by order_count desc;
is formatted with the Standard SQL dialect and UPPERCASE keywords as:
SELECT u.id, u.name, count(o.id) AS order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.active = 1 AND o.created_at >= '2026-01-01' GROUP BY u.id, u.name ORDER BY order_count DESC;
Each clause starts on its own line, the selected columns and grouped columns are listed one per line, and the second WHERE condition is moved onto its own AND line.
FAQ
Is my SQL sent to a server?
No. Formatting runs entirely in your browser using a local JavaScript library.
What if my query has a syntax error?
The tool shows a clear error message instead of crashing, so you can fix the query and try again.