SQL Formatter & Minifier
Beautify or compress SQL queries for readability or performance.
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
Keyword Capitalisation
Uppercases SQL keywords (SELECT, FROM, WHERE, JOIN) and lowercases identifiers for a consistent, readable style.
Dialect Support
Supports ANSI SQL, PostgreSQL, MySQL, SQL Server, and SQLite formatting conventions.
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.
Developer Insights
From the Blog
How Our SQL Prettifier Works Under the Hood
A technical walkthrough of our SQL formatter and the engineering decisions that handle edge cases gracefully.
Why JSON Formatting Matters More Than You Think
How proper JSON structure prevents production bugs, improves debugging, and makes code reviews faster.
The Case for 100% Client-Side Data Processing
Why we built OpenFormatter to process all data locally, and what that means for your workflow security.