SQL Formatter

Format and prettify SQL queries with proper indentation, keyword casing, and line breaks.

Developers cleaning up raw API responses or minified queries before code review.

How to use it

  1. Paste your SQL

    Copy your query — however messy — and paste it into the editor.

  2. Format or minify

    Click Format to prettify with indentation and uppercase keywords, or Minify to collapse it to one line.

  3. Copy the result

    Copy the formatted SQL into your code, migration, documentation, or review.

Why use this tool?

SQL has a habit of arriving as a single unreadable line — copied from application logs, an ORM’s output, or a colleague who never indents. A long SELECT with multiple joins, a WHERE clause, and a GROUP BY crammed onto one line is almost impossible to review or debug, and that is exactly when a subtle logic error hides in plain sight. This formatter rewrites your query with consistent keyword casing, sensible indentation, and line breaks before the major clauses, so the structure jumps out and you can actually read what the query does. It can also minify a query back to a compact single line when you need it for code or a config value. Formatting only touches whitespace and casing — the query logic is untouched — and everything runs in your browser, so your SQL (which may reveal schema or business logic) never leaves your device.

Common use cases

Code review

Format queries consistently before committing so reviewers can read them at a glance.

Debugging

Prettify a complex one-line query to see its structure and spot a misplaced join or condition.

Documentation

Include clean, well-indented SQL examples in docs, wikis, and runbooks.

Learning SQL

See how a query is structured by clause to understand how it executes.

Log analysis

Reformat a query pulled from application logs so you can read and re-run it.

Frequently asked questions

Is my SQL sent to a server?

No. All formatting happens in your browser, so your queries never leave your device.

Which SQL dialects are supported?

Standard SQL, with MySQL, PostgreSQL, and SQLite syntax generally handled well.

Does formatting change what the query does?

No. Only whitespace and keyword casing change; the logic and results are identical.

Can it format stored procedures?

Basic procedures format fine. Very complex PL/SQL or T-SQL blocks may not format perfectly.

Will it uppercase my table and column names?

No — it uppercases SQL keywords (SELECT, FROM, WHERE) while leaving your identifiers as written.

Can I minify as well as prettify?

Yes. Minify collapses the query to a single compact line for embedding in code or config.

Does it validate or run the query?

No. It only formats text; it does not check syntax against a database or execute anything.

Is it free?

Yes — format unlimited queries for free, with no account needed.

Related tools