SQL Formatter

Format and beautify SQL with proper indentation, or minify to a single line. Dialect-aware (ANSI / MySQL / Postgres).

Enter input above to see the result.

What is this for?

SQL ranges from a one-liner you typed in psql to a 200-line analytics query that nobody can read until it's indented properly. This formatter takes any SELECT, INSERT, UPDATE, or DDL statement and rewrites it with consistent indentation, line breaks before each clause, and uniform keyword casing. The minify mode does the opposite — squashes everything to a single line for embedding in code, YAML files, or CLI arguments. The whole thing runs in your browser; queries never leave the page.

When to use it

How it works

Common gotchas

Limitations and alternatives

This formatter handles indentation and casing well, but it's not a SQL linter or validator. For catching bugs, enforcing style rules, or running static analysis in CI/CD pipelines, use a dedicated tool like sqlfluff or pgFormatter. For dialect-specific features or complex parsing, consult your database engine's documentation.