SQL Formatter & Minifier

Beautify or compress SQL queries for readability or performance.

1234567891011121314151617181920
1234567891011121314151617181920

What Is a SQL Formatter?

A SQL formatter reformats SQL queries with consistent indentation, capitalisation of keywords, and line breaks — making complex SELECT statements, JOINs, subqueries, and CTEs easy to read and review.

Well-formatted SQL is essential for code reviews, documentation, and debugging. Raw SQL from ORM logs, query builders, or ad-hoc tools is often single-line and nearly unreadable without formatting.

Common Use Cases

  • check_circleFormat a SQL query from an ORM log before reviewing
  • check_circleBeautify a complex SELECT with multiple JOINs for documentation
  • check_circleReformat a single-line SQL query for debugging
  • check_circleNormalise SQL formatting in stored procedures before a code review
  • check_circleFormat CTEs and subqueries for easier comprehension
  • check_circleClean up auto-generated SQL from a query builder tool
auto_fix_high

Keyword Capitalisation

Uppercases SQL keywords (SELECT, FROM, WHERE, JOIN) and lowercases identifiers for a consistent, readable style.

verified

Dialect Support

Supports ANSI SQL, PostgreSQL, MySQL, SQL Server, and SQLite formatting conventions.

bolt

Instant Formatting

Paste any SQL query and get beautifully formatted output immediately.

Frequently Asked Questions

Does SQL formatting change query behaviour?

No. SQL is whitespace-insensitive outside string literals. Formatted SQL executes identically to the original.

Which SQL dialects are supported?

ANSI SQL, PostgreSQL, MySQL/MariaDB, Microsoft SQL Server (T-SQL), SQLite, and Oracle PL/SQL formatting conventions are supported.

Can I format SQL with CTEs?

Yes. WITH ... AS CTEs are formatted with correct indentation showing the CTE definition and the main query separately.

Does this validate SQL?

The formatter checks for basic syntax errors but does not execute the query. Full validation requires running the query against the target database.

SQL Formatter Online — Beautify & Format SQL | OpenFormatter | OpenFormatter