SQL Formatter
Format SQL for readability across dialects
What is SQL Formatter Tool?
SQL Formatter Tool is a tool for making SQL queries easier to read. It is useful when you want to clean up one-line SQL, fix broken indentation, or prepare a query for review or sharing.
The tool formats input in real time and lets you switch SQL dialect, indent width, and keyword case. That makes it useful for both quick cleanup and team-facing formatting.
How to Use
- Paste SQL into the input area.
- Review the formatted result.
- Adjust dialect, indent, and keyword case if needed.
- Use the output once it matches the style you want.
Main Settings
Language (SQL Dialect)
You can choose from Standard SQL, MySQL, MariaDB, PostgreSQL, DB2, SQLite, BigQuery, and Redshift. Picking the closest dialect helps the formatter produce a more familiar result.
Indent
You can switch between 2-space and 4-space indentation. This is useful when matching team preferences or making nested queries easier to scan.
Keyword Case
You can preserve the original case or convert keywords to uppercase or lowercase. This helps when aligning output with a coding style or review standard.
Use Cases
- Cleaning up one-line SQL before reviewing it
- Preparing queries for documentation or sharing
- Checking SQL with a dialect-aware formatter
- Making complex queries easier to inspect during debugging
Formatting Example
SELECT p.product_name,c.category_name,sum(s.sales_amount) as total FROM products p JOIN categories c ON p.category_id=c.id JOIN sales s ON p.id=s.product_id WHERE s.sales_date BETWEEN '2025-01-01' AND '2025-04-30' GROUP BY p.product_name,c.category_name HAVING sum(s.sales_amount)>1000 ORDER BY total DESC;
An input like this becomes easier to review once the query is split into readable lines and indentation.
Things to Keep in Mind
- Formatting changes presentation, not query behavior
- Non-standard syntax or unusual comments may not format as expected
- For very large queries, it is still worth checking the output carefully after formatting