SQL Formatter
Beautify and minify SQL queries. Configure keyword case, identifier case, indent width. Supports SELECT, INSERT, UPDATE, CREATE and all major SQL dialects.
Input SQL
SQL Formatter Tutorial
What This Does
Pastes in messy single-line SQL, produces readable multi-line SQL with consistent indentation and uppercase keywords. Also produces a minified one-line version for embedding in source code.
Powered By
The battle-tested sqlparse library — same parser used by Django's DB migrations tooling, DBeaver, and many SQL IDEs.
Common Use Cases
- Clean up generated SQL from an ORM log before sharing with a colleague
- Convert IDE-copied SQL to something readable in a code review
- Minify a pretty SQL for embedding in a single-line string literal
- Enforce house style (uppercase keywords, 2-space indent) on a pile of queries
Options
- Keyword case — normalize
SELECTvsselectvsSelect - Identifier case — optionally force table/column names to a case (leave unchanged if data has quoted identifiers)
- Indent width — 1 to 8 spaces
- Strip comments — remove
-- lineand/* block */comments
Dialect Support
sqlparse is a non-validating parser — it formats based on lexical structure, not a dialect's grammar. That means it works with MySQL, PostgreSQL, SQL Server, SQLite, Oracle, and most extensions (window functions, CTEs, JSON operators) without fuss. It does NOT catch syntax errors — that's by design.
Limits
Max input size 1 MB. Don't paste entire dumps — use mysql -p's built-in pretty-printer for those.