SQL Formatter

Paste a query that arrived from a log or an ORM as a single line, and read it as a query again — SELECT, FROM, WHERE and each JOIN on their own lines.

The code never leaves this page: formatting happens in your browser.

How to use

  1. Paste the query into the first box.
  2. Choose whether keywords go in capitals and whether each column gets its own line.
  3. Copy the result.

Good to know

Why literals are protected

A query may contain a column value like 'order by name' or a comment mentioning SELECT. A formatter that works with plain search and replace would break the line there or capitalise a word inside your data. Here, string literals and comments are set aside before formatting and put back afterwards, exactly as they were.

What the line breaks are for

Reading a query means finding three things fast: which tables it touches, how they are joined and what it filters by. Putting each clause on its own line answers all three at a glance, which is why this layout is the convention in code review — long before anyone runs the query.

Frequently asked questions

Which dialect does it support?

The clauses shared by PostgreSQL, MySQL, SQL Server and SQLite. Dialect-specific syntax is not reformatted, but it is not damaged either — unknown words pass through unchanged.

Does it check the query for errors?

No. It lays out what you give it and does not parse it. A broken query stays broken, just easier to read.

Is my query sent to a server?

No. Everything happens in your browser, which matters — queries carry table names, and often values from production.

Why are my keywords not capitalised?

Turn on «Keywords in capitals». It is a preference, not a rule: many teams write SQL entirely in lower case.

Related tools