Formatting SQL so it can be read
SQL copied from an application log, an ORM debug message or a colleague's chat arrives as one long line. Before you can review it, spot a missing condition or explain it to someone, it needs line breaks and indentation that show its structure: what is selected, from where, under which conditions.
This formatter puts each main clause on its own line, indents the clause bodies, keeps joins and conditions readable and writes keywords in upper or lower case, all in your browser.
How to use it
- Paste the SQL statement into the input box.
- Choose the indent width and whether keywords are written in UPPER or lower case.
- Read the formatted query on the right.
- Copy it into your editor, code review or documentation.
Example: a one-line query
select id, name from users where active = 1 and age > 30 order by name
SELECT id, name FROM users WHERE active = 1 AND age > 30 ORDER BY name
Each condition joined with AND starts its own line, so adding, removing or commenting out a condition is a one-line change.
Why formatting matters
A consistent layout turns SQL review into scanning. Clauses always appear in the same order, SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, and one condition per line makes a forgotten filter or an accidental OR visible at a glance. Version control diffs also get smaller, because a change touches one line instead of rewriting a long one.
Upper-case keywords are a convention, not a requirement: databases treat select and SELECT the same. Many teams prefer upper case so keywords stand out from table and column names.
What the formatter changes and what it keeps
It only changes whitespace and keyword case. Table names, column names, string literals and values are left exactly as written, so the formatted query runs the same way. It is a pretty-printer, not a validator: it does not check that tables exist or that the syntax is valid for your database.
The layout covers SELECT, INSERT, UPDATE and DELETE statements with joins and conditions. Very complex queries with nested subqueries or vendor-specific syntax are formatted on a best-effort basis; review the result before you rely on it.
Questions
Does it work for MySQL, PostgreSQL and SQL Server?
Yes for the common syntax all of them share. Vendor-specific keywords are kept but may not get their own line.
Is it safe to paste queries with real data?
The query never leaves your browser. Still, consider removing personal data from queries you share with others.
Can it fix a broken query?
No. It only changes layout. A clean layout often makes the error easy to find, though, such as a missing comma between two columns.