SQL Formatter

Free online SQL formatter that turns a cramped or minified query into neatly indented SQL across common dialects. Untangle nested subqueries and match your team's keyword style for code review, all processed locally in your browser.

SQL dialect
Keyword case
Input
Output

Usage examples

Cleaning up a one-line query copied from a log

Paste a long single-line query from an application log or slow query log and get it back broken into readable, clause-by-clause lines.

Improving readability for a code review or docs

Tidy a query's indentation before dropping it into a pull request or technical document so others can follow its structure at a glance.

Matching your team's keyword style

Convert keywords like SELECT and FROM to all-uppercase or all-lowercase to match your team's SQL style guide.

Untangling a nested subquery before optimizing it

Format a query with several levels of subqueries and JOINs so each level's indentation makes the logic clear before you rewrite it for performance.

Formatting a migration script before a PR review

Clean up a multi-statement ALTER TABLE or CREATE TABLE migration file so reviewers can see each column and constraint on its own line.

Frequently asked questions

Is my query sent to a server?

No. All formatting happens entirely in your browser, and what you enter is never sent to a server.

Does this actually run the query or connect to a database?

No. This tool only reformats the text for readability — it never connects to any database or executes anything.

How do I pick the right SQL dialect?

Choose the dialect matching the database you're using so dialect-specific syntax (like MySQL backticks or PostgreSQL operators) is recognized more accurately. If you're not sure, Standard SQL works fine for most queries.

What happens if there's a syntax error?

If the query has mismatched parentheses or a syntax error, formatting fails and an error message tells you roughly where the problem is.

Can I format multiple statements separated by semicolons at once?

Yes. Paste several statements in a row and each one is formatted in place, keeping the semicolons that separate them.

Does formatting change what the query does?

No. Only whitespace, line breaks, and keyword casing are changed — table names, column names, string literals, and the logic of the query itself are left exactly as written.

Why would I choose 'Preserve' instead of forcing uppercase or lowercase keywords?

Preserve keeps whatever casing you originally typed, which is useful when you've copied a query from somewhere and just want its layout cleaned up without second-guessing a style choice that was already made.