quialo.

SQL Formatter

Paste a SQL query above to format it.

Paste a messy SQL query and get a clean, indented version you can actually read. This formatter puts major keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) on their own lines, indents joins and conditions, and normalizes the spacing, all while leaving your string literals and quoted identifiers exactly as written. It runs entirely in your browser, so nothing you paste is sent anywhere.

How to use

  1. Paste your SQL query into the input box.
  2. Pick an indent width (2 or 4 spaces) and how you want keywords cased (uppercase, lowercase, or kept as typed).
  3. Read the formatted query in the output box, which updates as you type.
  4. Click Copy to grab the result, or Use result as input to format it again.
  5. Click Reset to clear everything and start over.

Examples

  • Input: select id, name from users where age > 18 order by name. Output puts SELECT, FROM, WHERE, and ORDER BY each on their own line.
  • Input with a join: SELECT u.id FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.active = 1 AND o.total > 100. The LEFT JOIN is indented and the AND starts its own line.
  • Input with a string literal: select * from t where name = 'GROUP BY test'. The text inside the quotes is preserved exactly and never reformatted.

FAQs

Is my SQL sent to a server?
No. The formatter runs fully in your browser using client-side JavaScript. Your query never leaves your device.
Will it change the meaning of my query?
No. It only adjusts whitespace, line breaks, and the case of recognized keywords. String literals, quoted identifiers, and comments are kept exactly as you typed them, so the query still does the same thing.
Does it validate my SQL?
No. This is a formatter, not a parser or linter. It reformats the text on a best effort basis and does not check that your query is valid or that the tables and columns exist.
Which SQL dialects does it support?
It uses a general set of common keywords (SELECT, FROM, JOIN, GROUP BY, and more) that work across most dialects like PostgreSQL, MySQL, SQL Server, and SQLite. Very dialect specific syntax may not be styled, but it will still be preserved.
Can I keep my keywords in their original case?
Yes. Choose Keep as typed under the Keywords selector and the formatter will only handle indentation and line breaks, leaving the case of every word untouched.
Why does a complex query not look perfect?
This is a heuristic formatter tuned for readability on common queries. Deeply nested subqueries or unusual syntax may format imperfectly, but your original text is never lost.

Related tools