SQL Query Formatter & Dialect Beautifier
Format, indent, and beautify messy SQL queries for PostgreSQL, MySQL, and ANSI SQL. Capitalize standard keywords, structure subqueries, and minify SQL strings.
SELECT u.id,
u.email,
u.full_name,
count (
o.id
) AS total_orders,
sum (
o.amount
) AS total_revenue
FROM users u
INNER JOIN orders o ON u.id = o.user_id
WHERE u.status = 'ACTIVE'
AND o.created_at >= '2026-01-01'
GROUP BY u.id,
u.email,
u.full_name
HAVING sum (
o.amount
) > 1000
ORDER BY total_revenue DESC
LIMIT 25 ;How to use this tool
Enter your raw SQL query into the left editor.
Select 2 spaces or 4 spaces indentation preference.
Copy clean, capitalized, clause-separated SQL code ready for pull requests or documentation.
Frequently Asked Questions
Which SQL dialects are supported?
The formatter follows ANSI SQL standards, fully compatible with PostgreSQL, MySQL, MariaDB, SQLite, Oracle, and Microsoft SQL Server syntax.
Are SQL comments preserved during formatting?
Yes. Both single-line comments (-- comment) and multi-line comments (/* comment */) are preserved in their respective positions.
Can I minify SQL queries for production configuration files?
Yes. Click 'Minify SQL' to strip comments, eliminate line breaks, and collapse multiple whitespace characters into a single compact string.
Is confidential database data safe when using this tool?
100% safe. The entire lexer and formatting logic runs locally inside your browser's JavaScript runtime; no query text is ever transmitted over the network.
Deepen your architecture knowledge with practical, production-tested guides:
Client-Side Privacy Guarantee
This tool never transmits your payloads to any server. Open DevTools (F12) → Network tab to verify that zero HTTP requests are sent while using this page.