Format complex SQL queries for maximum readability. Properly aligns JOIN clauses, indents subqueries, and highlights keywords. Supports MySQL, PostgreSQL, and ANSI SQL dialects.
Key Features
Uppercases or lowercases standard SQL reserved keywords (SELECT, WHERE, JOIN)
Indents subqueries, CASE statements, and nested expressions cleanly
Aligns clauses such as FROM, WHERE, GROUP BY, and ORDER BY
Supports multiple dialects including MySQL, PostgreSQL, SQLite, and SQL Server
How to Use
Paste your raw SQL query into the input editor.
Choose keyword casing (e.g. UPPERCASE for SQL keywords).
Click "Format SQL" to reformat the query.
Inspect the formatted query with clear indentation and alignment.
Copy the formatted query to use in your database client or code.
Example
Sample input
SELECT u.id,u.email FROM users u INNER JOIN orders o ON o.user_id=u.id WHERE o.status='paid' ORDER BY u.id DESC LIMIT 10;
Sample output
SELECT
u.id,
u.email
FROM users u
INNER JOIN orders o ON o.user_id = u.id
WHERE o.status = 'paid'
ORDER BY u.id DESC
LIMIT 10;
Edge Cases
Common Table Expressions (WITH clauses)
Dialect-specific functions (MySQL vs PostgreSQL)
Very long IN (...) lists
Frequently Asked Questions
Does formatting alter query results or execution plans?
No. SQL engines treat whitespace and casing of standard keywords identically. Query performance and execution plans are completely unaffected.
Can this tool format complex nested subqueries and CTEs?
Yes. Common Table Expressions (WITH clauses) and deeply nested subqueries are indented hierarchically for clear visual tracking.
Are string literals and quotes preserved properly?
Yes. Any text enclosed in single or double quotes, including comments, is preserved exactly without unintended casing changes.
Privacy notice: when you run this tool, your input is sent over HTTPS to our server, processed in memory and returned. It is not stored or logged. Avoid pasting live secrets such as private keys or passwords.