SQL Formatter
Format SQL queries
What Is This Tool?
The SQL Formatter reformats a SQL query by uppercasing major keywords and placing each clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and more — on its own line, with multi-column SELECT lists split one column per line. It uses a keyword-based, word-boundary-aware approach that protects quoted string literals so keyword-like text inside strings is never altered. Everything runs locally in your browser.
How to Use
Paste your SQL query into the input box.
Click Format.
Review the reformatted query.
Copy the result or download it as a .sql file.
Features
- Uppercases major SQL keywords
- Puts each major clause on its own line
- Splits multi-column SELECT lists one per line
- Leaves quoted string literals untouched
- Copy to clipboard or download as a file
- 100% client-side — nothing leaves your browser
Examples
Before:
select o.id, o.total, c.name, c.email from orders o inner join customers c on o.customer_id = c.id left join shipments s on s.order_id = o.id where o.status = 'shipped' and o.total > 100 order by o.total desc limit 20
After (formatted):
SELECT o.id, o.total, c.name, c.email FROM orders o INNER JOIN customers c ON o.customer_id = c.id LEFT JOIN shipments s ON s.order_id = o.id WHERE o.status = 'shipped' AND o.total > 100 ORDER BY o.total desc LIMIT 20
Common Use Cases
- Cleaning up a query copied from logs or a slow-query report
- Reviewing a long multi-join query during code review
- Making a hand-written query consistent with team style
- Preparing readable SQL examples for documentation
Frequently Asked Questions
Is my SQL uploaded anywhere?
No. Formatting happens entirely in your browser using JavaScript. Nothing is sent to a server.
Is this a full SQL parser?
No. This is a best-effort, keyword-based formatter, not a full SQL parser or query validator. It works well for typical SELECT, INSERT, UPDATE and DELETE statements but may not perfectly handle every dialect-specific construct.
Does it check whether my SQL is valid?
No, it does not validate syntax or check against a database schema. It only reformats the text you provide.
Will it change text inside quoted strings?
No, quoted string literals are extracted before keyword uppercasing and clause splitting, then restored afterward untouched.
Does it support every SQL dialect?
It recognizes common ANSI SQL keywords used across MySQL, PostgreSQL, SQL Server and similar databases, but dialect-specific syntax may not be specially formatted.
Can I download the result?
Yes, click Download to save the current output as a query.sql file.