Practical guides on IT careers, blogging & online income for beginners.

SQL Formatter & Beautifier

Turn a one-line SQL query into something you can read. Keywords are tidied, clauses go on their own lines, subqueries are indented and your original logic is never touched.

  • Free
  • No sign-up
  • Runs in your browser

Everything runs in your browser. What you type here is never uploaded, stored or sent anywhere.

What does a SQL formatter do?

A SQL formatter takes a query and re-lays it out so it is easy to read: each clause (SELECT, FROM, WHERE, GROUP BY) starts on its own line, columns are listed one per line, JOIN conditions are indented under the join, and subqueries sit inside their own indented block.

Formatting changes only whitespace and the letter case of SQL keywords. Your table names, column names, string values and comments are left exactly as written, so the query returns the same result before and after. That makes it safe to use on queries pulled out of logs, ORMs and slow-query reports, which usually arrive as a single unreadable line.

It understands the common dialects (MySQL, PostgreSQL, SQLite and SQL Server), including backtick and bracket identifiers, :: casts and ?, :name, @var and $1 placeholders. Need to build a query from scratch instead? Use the SQL Generator. Have data in a spreadsheet you want to load? Try the CSV Converter.

How to format a SQL query

  1. Paste your SQL into the input box, or click Load sample to see an example. You can paste several statements at once.
  2. Choose the indent size and whether keywords should be upper case, lower case or left as they are.
  3. Click Format. The clean version appears on the right.
  4. Need it on one line for a log message or config value? Click Minify instead.
  5. Copy the result or download it as a .sql file.

Why developers reach for it

  • Reading a long query copied from an ORM debug log or a slow-query log.
  • Making a pull request easier to review by cleaning up inline SQL.
  • Spotting a missing JOIN condition or a misplaced AND and OR in a WHERE clause.
  • Keeping SQL files consistent across a team, with one agreed keyword case and indent size.
  • Shrinking SQL to a single line before embedding it in code or a JSON config.

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace and the case of keywords change. Strings, identifiers, numbers and comments stay exactly as you wrote them. If you pick Keep as typed for keyword case, even the letter case stays the same.

Which SQL dialects does it support?

It works well with MySQL and MariaDB, PostgreSQL, SQLite and SQL Server (T-SQL). It recognises backtick, double-quote and bracket identifiers, :: casts, and placeholders like ?, :name, @var and $1. Very vendor-specific syntax, such as full stored-procedure bodies, is laid out on a best-effort basis.

Is my SQL sent to a server?

No. Everything is processed in your browser. Your queries, table names and data never leave your device.

Does it check whether my SQL is valid?

No. It is a formatter, not a database. It lays out whatever you give it, so a query with a typo will still be formatted. To test that a query runs, use your database client.

Should SQL keywords be upper case?

It is a convention, not a rule. Upper-case keywords make the structure of a query stand out from table and column names, so many teams prefer it. Pick whichever style your team uses and stay consistent.

Can it format several statements at once?

Yes. Statements separated by semicolons are formatted one after another with a blank line between them.