SQL Formatter
Make messy SQL readable in one click. Paste your query, and this tool uppercases the keywords, puts each major clause on its own line, and indents the parts inside it. String literals are left exactly as you typed them. Copy the clean result when you are done.
Your SQL
Formatted SQL
—
Paste SQL on the left to see the formatted result here.
Worked Example
Example. Paste "select id, name from users where age > 18 order by name" and the tool returns four lines: "SELECT" on the first line, two spaces then "id, name" on the second, "FROM users" on the third, "WHERE age > 18" on the fourth, and "ORDER BY name" on the fifth. The keywords are uppercased, each clause starts its own line, and the column list is indented under SELECT.
Common Mistakes
Pasting SQL with mixed case and no line breaks. A long query on one line is hard to read and easy to mis-edit. Format it first, then read the clauses top to bottom before changing anything.
Editing inside a string literal by accident. Text inside single quotes is data, not code. This formatter never changes string literals, so check that a value you want to change is really a value, not a column name.
Trusting the format to fix the logic. Formatting only changes how the query looks. It does not check that the tables exist, that the joins are right, or that the WHERE clause filters what you intend. Test the formatted query before running it on live data.
Forgetting the semicolon. A trailing semicolon is kept as typed. If your tool needs one, add it before you copy the result out.
Related Tools
Make a unique ID with the UUID Generator, shrink text with the Gzip Text Compressor, turn text into pictures with the ASCII Art Generator, or browse every calculator in the Tools hub.
Frequently Asked Questions
Does the formatter change my string values?
No. Text inside single quotes is lifted out before formatting and put back exactly as typed, so a value like 'select' stays lowercase and untouched while the real SELECT keyword is uppercased.
Which keywords get uppercased?
SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT, INSERT, UPDATE, DELETE, and the usual helpers like AND, OR, AS, DISTINCT, ASC, and DESC. Column and table names keep the case you typed.
How are clauses laid out?
Each major clause starts on its own line: SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, and each JOIN. The column list under SELECT is indented, and AND and OR inside a WHERE clause each start a new indented line.
Does it check my SQL for errors?
No. This is a formatter, not a validator. It rearranges the text in a fixed, deterministic way. Run the result in your database tool to check that it is valid.
Can I format more than one statement at once?
Yes, you can paste several statements, but they are formatted as one block of text. For the cleanest result, format one statement at a time.