~/tools/sql-formatter
SQL Formatter
Format, beautify, and minify SQL queries with dialect-aware formatting. Supports MySQL, PostgreSQL, T-SQL, SQLite, BigQuery, and more. Runs entirely in your browser.
What is a SQL Formatter?
A SQL formatter (also called a SQL beautifier) automatically restructures raw SQL queries into a consistent, readable format. It enforces indentation, keyword casing, and line breaks so queries are easy to read, review, and maintain — regardless of how they were originally written.
SQL formatting is critical in professional environments where multiple developers write queries — consistent style reduces cognitive load during code review, makes diffs easier to read, and helps catch logical errors that are obscured by poor indentation.
Supported Dialects
Format vs Minify
Format (Beautify)
Expands a compressed or unformatted query into a multi-line, indented, human-readable form. Best for code review, debugging, and documentation.
Minify (Compress)
Collapses a formatted query into a single line with minimal whitespace. Useful for embedding SQL in code strings, reducing payload size, or obfuscating query structure.
Common Use Cases
Code Review
Normalize query formatting before committing to version control so diffs reflect logic changes rather than whitespace differences.
ORM Output Cleanup
ORMs like Hibernate, ActiveRecord, and Prisma often generate hard-to-read SQL. Format the logged query to understand what's being executed.
Legacy Query Migration
Clean up old, inconsistent SQL when migrating from one database system to another or refactoring stored procedures.
Documentation
Format queries for README files, blog posts, or internal wikis so readers can follow query structure without effort.
Query Debugging
Unminify a compressed SQL string from a log file or error report to identify exactly which clause caused the issue.
Interview Prep
Practice writing clean, consistently formatted SQL that meets professional coding standards expected in technical interviews.