SQL Formatter
Format and beautify SQL queries with automatic indentation and keyword uppercasing. Paste messy SQL, get clean output.
Formatted SQL will appear here…SQL formatting before and after
Paste your raw SQL — output by ORMs, query builders, or log files — and get clean, readable output:
Before
select u.id,u.name,o.total from users u inner join orders o on u.id=o.user_id where o.total>100 and u.active=1 order by o.total desc limit 10
After
SELECT u.id, u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id WHERE o.total > 100 AND u.active = 1 ORDER BY o.total DESC LIMIT 10
SQL formatting conventions
- UPPERCASE keywords —
SELECT,FROM,WHERE,JOINin uppercase improves scannability and separates SQL structure from data names. - One clause per line — put
SELECT,FROM,WHERE,ORDER BYon separate lines to make the query structure immediately visible. - Indent continuation lines — indent
ONclauses andAND/ORconditions by 2 spaces to show they belong to the clause above. - Aliases consistently — use
ASor short aliases consistently:users uorusers AS u.
Related Tools
Frequently Asked Questions
What SQL dialects are supported?
The formatter handles standard SQL keywords common across MySQL, PostgreSQL, SQLite, SQL Server, and Oracle. It formats SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and more.
Does it modify my SQL logic?
No. The formatter only changes whitespace, indentation, and optionally the case of keywords. Your query logic, table names, and values remain untouched.
Can I minify SQL instead?
Yes. Use the Minify button to compress your SQL into a single line, removing all unnecessary whitespace. Useful for embedding in code or reducing payload size.
Is my SQL sent to a server?
No. All formatting happens in your browser. Your queries never leave your device.