SQL Formatter & Validator
Format and beautify SQL queries with dialect support.
How it works
- 1
Paste your SQL
Paste your SQL query into the input area.
- 2
Choose options
Select your SQL dialect, indentation size, and keyword casing preference.
- 3
Format and copy
Click Format to beautify your SQL. Copy the formatted output.
Common use cases
SELECT query
select id,name,email from users where active=1 order by name
JOIN query
select u.name,o.total from users u join orders o on u.id=o.user_id where o.total>100
About This Tool
Format, beautify, and validate SQL queries with this free online SQL formatter. Paste any SQL statement and instantly get a cleanly indented, readable version.
Supports six popular SQL dialects: Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL (SQL Server), and PL/SQL (Oracle). Choose between 2-space and 4-space indentation, and optionally uppercase all SQL keywords for a consistent coding style. The formatter preserves both single-line and multi-line comments. If your SQL contains syntax errors, the tool shows a clear warning message.
All formatting runs entirely in your browser using the sql-formatter library -- your queries are never sent to any server, making this tool safe for use with production database queries and sensitive data.
More examples
Examples
SELECT query
Input
select id,name,email from users where active=1 order by name
Output
SELECT id, name, email FROM users WHERE active = 1 ORDER BY name
JOIN query
Input
select u.name,o.total from users u join orders o on u.id=o.user_id where o.total>100
Output
SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > 100
Frequently Asked Questions
- Which SQL dialects are supported?
- Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL (SQL Server), and PL/SQL (Oracle). Select your dialect from the dropdown for dialect-specific formatting.
- Does this validate my SQL?
- The formatter checks for basic syntax structure. If your SQL has severe syntax errors, it will show a warning. However, it is not a full SQL parser -- some valid but unusual syntax may trigger warnings.
- Are comments preserved?
- Yes. Both single-line (--) and multi-line (/* */) comments are preserved in the formatted output.
- Is my SQL sent to a server?
- No. Formatting runs entirely in your browser. Your queries never leave your device.