Paste messy SQL and get clean, readable queries with consistent indentation and keyword casing. Free, no signup.

Home › Developer Tools › SQL Formatter

SQL Formatter — Make Messy SQL Readable in One Click

Paste a tangled query and get clean, consistently indented SQL: uppercase keywords, one clause per line, and neatly indented subqueries. Perfect for code reviews, documentation, and debugging.

100% private

Formatting runs entirely in your browser. Your queries are never uploaded, logged, or stored anywhere.

No signup

No account, no email, no install. Paste your SQL and format it instantly, as often as you like.

Free forever

Unlimited SQL formatting with keyword-case and indent options — free, with no limits.

How to use the SQL formatter

  1. 1Paste your SQL

    Drop in a query from your app, database console, or ORM log — single-line messes and minified SQL work fine.

  2. 2Pick your style

    Choose uppercase or lowercase keywords and an indent of 2 spaces, 4 spaces, or a tab to match your team's style guide.

  3. 3Format and review

    Click Format SQL. Each major clause lands on its own line, JOINs and conditions indent cleanly, and subqueries nest one level deeper.

  4. 4Copy or download

    Copy the result to your clipboard or download it as a ready-to-run .sql file.

Why developers use this SQL formatter

One clause per line

SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY each start on their own line, so long queries scan at a glance.

Clean subquery indentation

Nested queries indent one level deeper and their closing parenthesis lines up, so nesting depth is obvious.

Consistent keyword casing

Normalize every keyword to UPPERCASE or lowercase in one pass — no more mixed-case queries in pull requests.

Safe with strings and comments

Quoted strings, escaped quotes, line comments, and block comments pass through untouched — the formatter never rewrites your data.

BETWEEN handled correctly

The AND inside a BETWEEN range stays on the same line instead of being split into a new condition.

Works with every dialect

Standard SQL formatting that reads well for MySQL, PostgreSQL, SQL Server, SQLite, and Oracle queries alike.

SQL formatter FAQs

Does this formatter change what my query does?
No. Formatting only changes whitespace and keyword casing. It never reorders clauses, renames columns, or alters string literals, numbers, or comments, so the formatted query returns exactly the same results.
Which SQL dialects does it support?
It formats standard SQL syntax used by MySQL, PostgreSQL, SQL Server, SQLite, and Oracle. Dialect-specific extras (like backtick quoting or T-SQL brackets) are preserved as written.
How are subqueries formatted?
An opening parenthesis starts a new indented block, the inner query is formatted normally one level deeper, and the closing parenthesis drops back to the outer indent — so nested SELECTs are easy to follow.
Why does BETWEEN keep its AND on the same line?
The AND in "BETWEEN x AND y" is part of the range, not a separate WHERE condition. The formatter detects that case and keeps the range together instead of splitting it across lines.
Can I format very long queries?
Yes — formatting runs locally in your browser, so even multi-hundred-line queries format instantly with no upload and no size cap beyond your browser's own limits.
Is my SQL private?
Completely. Every byte of formatting happens in your browser. Nothing is sent to a server, so proprietary queries and production data stay on your machine.
Does it validate my SQL?
No — this is a formatter, not a validator. It will neatly format syntactically broken SQL too, which can actually help you spot the mistake. Run the result in your database to check it executes.
Scroll to Top