SQL Formatter

Beautify messy SQL into readable, indented output — or minify it back down.

Runs in your browserNo sign-up required
SQL Input
SELECT id,
  name,
  email
FROM users
WHERE status = 'active'
AND age > 18
ORDER BY created_at DESC
LIMIT 10

Readable In, Compact Out — Either Direction

Paste a single dense line of SQL and get properly indented, keyword-capitalized output broken at each major clause — or go the other way and collapse a nicely-formatted query back down to one compact line for embedding directly in application code.

How to Use This Tool

  1. 1Paste SQLMinified, poorly indented, or just inconsistently formatted.
  2. 2Pick Format or MinifyFormat breaks it onto readable, indented lines; Minify collapses it back down.
  3. 3Copy the resultReady to paste into a query tool, migration file, or application code.

Good to Know

  • This is a keyword-based formatter, not a full SQL parser for any one specific dialect — it reliably handles standard clause structure (SELECT/FROM/WHERE/JOIN/GROUP BY/ORDER BY and similar) across MySQL, PostgreSQL, and SQL Server alike.
  • String literals are protected during formatting, so a keyword that happens to appear inside a quoted string won't get capitalized or broken onto its own line by mistake.
  • Minify mode is the direct reverse of Format — useful when embedding a query as a single-line string in application code where extra whitespace and line breaks aren't wanted.
  • Formatting doesn't validate that the SQL is actually correct — it reformats whatever structure is there, valid or not.

Frequently Asked Questions

Does this support every SQL dialect equally?

The formatting itself is dialect-agnostic — standard clause keywords and structure look the same across MySQL, PostgreSQL, and SQL Server. Dialect-specific syntax quirks (like SQL Server's square-bracket identifiers) aren't rewritten, just left as typed.

Will this catch syntax errors in my SQL?

No — it reformats the text structure without parsing it into a validated query, so invalid SQL will still be reformatted (not fixed) into a readable but still-invalid shape.

Why did a keyword inside a string get left alone?

Text inside quoted string literals is intentionally left untouched during formatting — only real SQL keywords outside of quotes are capitalized or used as line-break points.

Is this free to use?

Yes, completely free, with no limit on query length or how often you use it.