What is a SQL Formatter?
A SQL formatter (also called a SQL beautifier or pretty printer) takes a raw or minified SQL query and re-indents it with consistent spacing and line breaks — making it significantly easier to read, review and debug.
How to Use This Tool
- Paste your SQL query into the SQL Input panel.
- Choose your preferred keyword case (UPPERCASE is the SQL convention), dialect and indent size.
- Click Format SQL or press Ctrl + Enter.
- Copy the result with the Copy button.
Use Minify to collapse a formatted query back to a single line — useful for embedding SQL in application code or config files.
What Gets Formatted
| Element | Behaviour |
|---|---|
| SELECT, FROM, WHERE … | Each clause starts on a new line |
| AND, OR | Indented on their own line within WHERE / HAVING |
| JOIN, LEFT JOIN, INNER JOIN … | Each join starts on a new line |
| ON | Indented below the JOIN it belongs to |
| GROUP BY, ORDER BY | Each on a new line |
| LIMIT, OFFSET, HAVING | Each on a new line |
Keyword Case Options
- UPPERCASE — the most common SQL convention; keywords stand out visually from identifiers
- lowercase — preferred in some codebases and ORMs
- Preserve — leaves keywords exactly as typed
SQL Dialects
- Standard SQL — ANSI-compliant formatting suitable for most databases
- MySQL — recognizes MySQL-specific keywords such as SHOW, ENGINE, AUTO_INCREMENT
- PostgreSQL — handles PostgreSQL extensions like RETURNING, ON CONFLICT, and dollar-quoted strings
Choosing the right dialect ensures that database-specific keywords are formatted and cased correctly rather than treated as identifiers.
Indent Size
Two-space indentation is compact and common in front-end codebases. Four-space indentation (the default in most SQL editors) provides greater visual separation between nested clauses and subqueries. Both produce identical query logic — the choice is purely stylistic.
When to Use Minify
Minified SQL (collapsed to a single line) is useful when:
- Embedding a query inside a JSON configuration or environment variable
- Comparing two queries character by character
- Logging SQL in systems that store one statement per line
The minifier removes all unnecessary whitespace and newlines while preserving string literals and comments unchanged.
Privacy
This tool runs entirely in your browser. No SQL is ever sent to a server, stored in cookies, or logged anywhere.