sql-formatter

Paste a messy SQL query to format and indent it, or minify it for logging and storage. Keyword capitalisation, clause indentation, and JOIN formatting handled automatically.

client-side only T-SQL / PostgreSQL / MySQL format + minify no signup
Indent spaces
Comma
input.sql
output.sql

// what this formats

// what this does not do

This is a keyword-aware formatter, not a full SQL parser. It does not resolve table aliases, validate that column names exist, or understand stored procedure / function body blocks (BEGIN…END) as deeply as a dialect-specific tool would. For complex PL/pgSQL, T-SQL stored procedures with control flow, or dynamic SQL, the formatting output is best-effort — check the result before using it in a migration or deployment script.

// minifying SQL

Minified SQL is identical in execution to formatted SQL — it's just whitespace removed. Useful when logging queries (a compact string is much easier to search in a log aggregator than a formatted multi-line one), embedding SQL in application config files where line breaks would be awkward, or storing parameterized query templates where size matters. Minifying does not remove comments — strip those manually if you don't want them in the output.