🗄️

SQL Formatter

Format and beautify SQL queries for better readability.

Input
Formatted SQL

📖 What is SQL Formatter?

This SQL Formatter takes unformatted SQL queries and restructures them with proper keyword capitalization, indentation and line breaks. Readable SQL is easier to understand, review, debug and maintain — especially for complex queries with multiple JOINs and subqueries.

💡 Example

Input
select u.id,u.name from users u inner join orders o on u.id=o.user_id where o.total>100 order by o.total desc
Output
SELECT u.id, u.name FROM users u INNER JOIN orders o ON u.id = o.user_id WHERE o.total > 100 ORDER BY o.total DESC

🛠️ Common Use Cases

  • Formatting SQL before committing to version control
  • Making complex queries readable for code review
  • Cleaning up auto-generated ORM queries
  • Documenting database queries
  • Debugging slow queries before running EXPLAIN

❓ Frequently Asked Questions

Does formatting change how SQL runs?
No — formatting only changes whitespace. The execution plan and results are identical. Formatting is purely cosmetic for readability.
Should SQL keywords be uppercase?
By convention yes, but it's not required. Uppercase keywords (SELECT, FROM, WHERE) make them stand out from table/column names, improving readability.
Does this support all SQL dialects?
The formatter handles standard SQL keywords. Most syntax works for MySQL, PostgreSQL, SQLite and SQL Server. Dialect-specific features may not be perfectly formatted.
🔒
Your data stays private. All processing happens entirely in your browser using JavaScript. Nothing is ever sent to our servers. You can even use this tool offline after the page loads.