SQL Formatter & Beautifier — Readable Queries

Turn a wall of one-line SQL into readable, indented clauses — or collapse it back — with Select/From/Where on their own lines and joins kept with their clause.

—

What this tool does

SQL is whitespace-insensitive, so it often arrives as one long line — pasted from a log, an ORM, a SHOW CREATE dump or a colleague's message. That line is correct but hard to read: the clauses blur together and a join condition is easy to misread. This formatter puts each clause on its own line and indents what belongs to it, so the structure of the query becomes visible. It is purely cosmetic — the query does exactly the same thing before and after.

How the formatting works

ElementHow it is laid out
Main clausesSELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT — each starts at column 0
Clause itemsIndented one level under their clause, one per line
JOINsEach JOIN starts a new line; its ON condition stays with it
AND / ORKept inline so a WHERE condition reads as one expression
ParenthesesOpen a nested indent, so a subquery is clearly contained
Strings & commentsPreserved exactly, never re-wrapped or re-cased

Keyword case

There are two schools: uppercase keywords (SELECT … FROM) make the structure pop against lowercase identifiers, while some teams prefer everything lowercase for a calmer read. The keyword case selector does either, or leaves your input untouched. Only reserved words are affected — identifiers, table names and string literals are never re-cased, so a column called select stays exactly as you wrote it.

What it is not

This is a formatter, not a linter or a database. It does not tell you whether a query is valid, does not know your schema, and does not connect to anything. For a query that refuses to run, the error will come from your database, not from here — this tool's job is only to make the text, once it is correct, readable.

Frequently asked questions

What does this formatter do?

It re-lays-out a SQL statement so it is readable: each main clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY — starts on its own line, the items inside a clause are indented, and joins and boolean connectors stay with their clause. A one-line query dumped from a log becomes something you can actually read and review.

Does it validate or execute my SQL?

No. It is a formatter, not a parser or a database. It tokenises the text and re-emits it with whitespace changed, without connecting to anything or checking that the statement is legal. It never sends your query anywhere.

Will it change what my query does?

No. Formatting only changes whitespace between tokens. Strings, numbers, identifiers, comments and operators are preserved character for character, and the only other change is upper- or lower-casing keywords if you ask for it. A formatted query is the same query.

Which database dialects are supported?

The common surface shared by SQLite, MySQL, PostgreSQL and SQL Server — SELECT/INSERT/UPDATE/DELETE, CREATE/ALTER/DROP, JOINs, subqueries, CASE expressions and comments. It is not a per-dialect grammar, so exotic vendor syntax may format imperfectly, but ordinary queries come out clean.

Can I go the other way and compress it?

Yes. The Minify button collapses the statement back to a single line and the keyword-case selector still applies. Minify only removes inter-token whitespace; it does not alter literals, so the result stays faithful to the input.

Is my query uploaded?

No. The whole formatter runs in your browser. Queries often carry table and column names, so nothing is sent to a server and nothing is stored.

Sources

  • ISO/IEC 9075 (SQL) — the clause structure the line breaks follow.

Everything runs in your browser — nothing you type is uploaded.