About this SQL formatter
Queries copied from logs, ORMs, or a colleague’s message often arrive on one long line. This formatter puts SELECT, FROM, WHERE, GROUP BY, ORDER BY, and the other clauses on their own lines, lists selected columns one per line, keeps each JOIN with its ON condition, starts AND and OR conditions on new lines, and indents subqueries and WITH (CTE) blocks. Strings, quoted identifiers, and comments are left exactly as written, and only the layout and, if you choose, the keyword case change, so the query does the same thing afterwards.
How to format SQL
- Paste your SQL. Paste one query or several statements separated by semicolons, or press an example. An example only fills the box.
- Pick the settings. Choose the dialect, the indentation, and whether keywords are uppercased and comments kept.
- Press Format SQL. The formatted query appears below.
- Copy or clear. Press Copy SQL or Download, or press Clear to start again.
Frequently asked questions
Can formatting change what my query does?
No. Only spaces, line breaks, and optionally the letter case of keywords change. Strings, numbers, identifiers, and operators stay exactly as they were.
What changes between the dialects?
MySQL also treats # as the start of a comment and understands backtick identifiers; PostgreSQL understands $$ quoted bodies and operators such as ::, ->>, and @>. Standard SQL handles everything else the same way.
Are table and column names uppercased too?
No. Uppercase keywords only changes SQL keywords and common functions such as SELECT, JOIN, COUNT, and COALESCE. Your table, column, and alias names keep their case.
Does it check my SQL for errors?
No. It formats the query without running or validating it, so a query with a typo is still formatted. Run it in your database to find syntax errors.
Can I format several statements at once?
Yes. Separate them with semicolons; each statement is formatted and separated from the next by a blank line.