SQL Formatter
Paste a SQL query and get it back with clauses on their own lines, indented lists and optional capital keywords. Nothing is run.
Use the tool
Loading the tool…
About SQL Formatter
Format SQL queries so they are easier to read. Choose readable lines or one line, the indent (2 spaces, 4 spaces or a tab), and whether to write keywords in capitals. You can also choose to remove comments when you put the query on one line.
Worked example
Paste a SELECT query with several conditions. The readable layout puts each clause on its own line, with keywords in capitals.
Limits
Formatting does not check the query's logic or its speed. Test the query on a copy of your data before you run it on live data.
How to use SQL Formatter
- Paste your SQL.
- Choose readable lines or a single line.
- Choose the indent size and whether keywords are capitals.
- Copy the result.
Good to know
- Strings and quoted names are never changed.
- The one-line layout removes comments, because a line comment would otherwise hide the rest of the query.
- This is a general formatter and does not know every dialect, so read the result before you run it.
- Your SQL is never connected to a database.
Frequently asked questions
Does it check my SQL is correct?
No. It rearranges the text but does not check it against a database or a dialect.
Does it change my strings?
No. Quoted text and names are copied exactly.
Is my SQL saved or sent?
The work happens in your browser on this page, and nothing is stored or sent to us.