How to use SQL Formatter
- 1
Paste your SQL query into the Input panel.
- 2
Click "Format SQL" to beautify it.
- 3
Use "Minify" to compact the query into a single line.
- 4
Copy or download the formatted output.
Beautify and format SQL queries with proper indentation, keyword uppercasing, and clause-level line breaks.
Paste your SQL query into the Input panel.
Click "Format SQL" to beautify it.
Use "Minify" to compact the query into a single line.
Copy or download the formatted output.
Standard SQL keywords work across MySQL, PostgreSQL, SQLite, and SQL Server. Dialect-specific constructs (PostgreSQL $$ blocks, MySQL backtick identifiers, T-SQL DECLARE) are formatted as-is without syntax errors.
No — formatting is done entirely in your browser using JavaScript. Your SQL queries (which may contain sensitive schema or data) never leave your device.
No — formatting only affects whitespace, case, and line breaks. The query logic, table names, column names, and values are not modified. The formatted output executes identically to the original.
The tool handles standard DML and DDL statements well. Very complex stored procedures with BEGIN/END blocks or procedural language (PL/pgSQL, T-SQL) may not format perfectly — it is optimized for standard SELECT/INSERT/UPDATE/DELETE queries.
Minify removes all whitespace and collapses the query to a single line — useful for embedding SQL in config files, URL parameters, or logging where whitespace waste is a concern.
The formatter uppercases SQL reserved keywords (SELECT, FROM, WHERE). If your table or column names happen to match a keyword (e.g. a column named "group" or "order"), wrap them in backticks or quotes.
ORM debug output. A copied query from a monitoring dashboard. Legacy stored procedures. All of them arrive looking like this:
SELECT u.id,u.name,u.email,o.total,o.created_at FROM users u INNER JOIN orders o ON u.id=o.user_id WHERE o.total>100 AND u.status='active' AND u.created_at>'2024-01-01' ORDER BY o.total DESC LIMIT 20 OFFSET 0
And after formatting:
SELECT
u.id,
u.name,
u.email,
o.total,
o.created_at
FROM users u
INNER JOIN orders o
ON u.id = o.user_id
WHERE o.total > 100
AND u.status = 'active'
AND u.created_at > '2024-01-01'
ORDER BY o.total DESC
LIMIT 20
OFFSET 0
Same query. The formatted version shows you the JOIN condition, the three WHERE clauses, and the sort order at a glance. The minified version requires counting commas to know there are five selected columns.
Keyword uppercasing: SQL conventions (and many style guides) require keywords in uppercase. select, from, where become SELECT, FROM, WHERE — clearly distinguishing keywords from table and column names.
Clause-level line breaks: Each major clause (SELECT, FROM, JOIN, WHERE, AND/OR, ORDER BY, GROUP BY, HAVING, LIMIT) moves to its own line, creating a top-to-bottom readable structure.
SELECT-list indentation: When multiple columns are selected, each column appears on its own indented line — making it easy to see exactly what the query returns.
Subquery indentation: Inline subqueries inside parentheses are indented an extra level, visually separating them from the outer query.
Minify mode: Strips all indentation and line breaks to produce a single-line query — useful for embedding SQL in logs, string constants, or API payloads.
The formatter applies standard ANSI SQL formatting rules, which work well across:
| Database | Compatibility |
|---|---|
| PostgreSQL | ✅ Full support |
| MySQL / MariaDB | ✅ Full support |
| SQLite | ✅ Full support |
| Microsoft SQL Server (T-SQL) | ✅ Core SQL formatting |
| Oracle SQL | ✅ Core SQL formatting |
| BigQuery / Redshift | ✅ Most syntax |
Dialect-specific procedural extensions (PL/pgSQL BEGIN...END blocks, T-SQL DECLARE, stored procedure syntax) may format imperfectly — the formatter handles standard SQL queries, not full procedural code.
Debugging ORM queries: ActiveRecord, Hibernate, Elo...
Looking for a more detailed deep-dive and advanced tips?
Read Full Article on our BlogYour data never leaves this device. All processing is handled locally by JavaScript.
Format and beautify SQL queries with proper indentation and keyword uppercasing.