SQL formatter (format SQL online)

This SQL formatter turns a messy query into readable code: paste it, copy the result. It writes keywords in uppercase, breaks SELECT lists, conditions and joins onto lines and indents subqueries. String literals and identifiers stay untouched. Your query never leaves the browser.

Source: PostgreSQL-Dokumentation – Lexical Structure (Bezeichner, Zeichenketten, Kommentare, Dollar-Quoting). Updated: .

Paste one or more statements (SELECT, INSERT, UPDATE, DELETE, WITH, CREATE TABLE …).

Your text stays in your browser – it is not sent, not stored and not added to the address bar.

For several statements separated by semicolons.
My ToolboxYour inputs are saved in this browser only.

Result

Result
SELECT u.id, u.name, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 AND o.total > 100 GROUP BY u.id, u.name ORDER BY orders DESC LIMIT 10
Size
1 statement(s), 13 lines, 183 → 195 characters.

How it is calculated

An unformatted SQL query on a single line is hard to read, review and compare. The formatter turns it into a clear query without changing its meaning.

How to format SQL

  1. Paste the query into the box (several statements separated by ; are fine).
  2. Choose Format under “Action”; set keyword case, indentation and comma style.
  3. Copy the result.

What the formatter does

Uppercase or lowercase?

SQL keywords are case-insensitive (ISO/IEC 9075). Uppercase is a common convention so keywords stand out from table and column names; how unquoted identifiers are treated depends on the database, and the tool does not touch them.

Minify

“Minify” turns the query into one line without superfluous spaces and removes comments (optimizer hints /*+ … */ are kept). Handy for embedding SQL in code or config files.

Limits

Frequently asked questions

How can I format SQL online?

Paste the query into the box – the formatted result appears immediately and can be copied. Processing happens in your browser; nothing is sent.

Does the formatter change my query?

Only whitespace, line breaks and (if you wish) the case of keywords. String literals, identifiers, numbers and operators are preserved character for character; the tool is checked with test cases for exactly that.

Do SQL keywords have to be uppercase?

No. Keywords are not case-sensitive. Uppercase is only a readability convention – choose “Keep as typed” or “lowercase” if your team does it differently.

How do I format a date or numbers in a SQL query?

That is something else: this tool formats the text of the query, not its results. To format output you use database-specific functions such as TO_CHAR (PostgreSQL, Oracle), DATE_FORMAT (MySQL) or FORMAT (SQL Server).

Which SQL dialects are supported?

The tool is dialect-neutral and copes with common queries from PostgreSQL, MySQL/MariaDB, SQL Server, SQLite and Oracle. Database-specific procedural code is not indented separately.

Are my SQL queries stored or uploaded?

No. The query is processed in the browser only, not stored and not added to the address bar – important when table or column names come from a production system.

Sources and legal basis

As of:

Related tools