>Fafa Dev Tools

SQL Formatter

Format and beautify SQL queries online. Free SQL formatter supporting MySQL, PostgreSQL, SQL Server, and more. Instant conversion.

0 chars
Output will appear here...

What is SQL Formatter?

A SQL formatter takes messy, hard-to-read SQL queries and reformats them with proper indentation, line breaks, and keyword capitalization. This makes queries easier to understand, review, and debug. Supports multiple SQL dialects including MySQL, PostgreSQL, SQL Server, and SQLite.

How to Use

  1. Paste your SQL query in the input area
  2. Select the SQL dialect (MySQL, PostgreSQL, etc.)
  3. Click Format to beautify or Minify to compress
  4. The formatted result appears instantly
  5. Download as a .sql file

Examples

Format a SELECT query

InputSELECT u.id,u.name,o.total FROM users u INNER JOIN orders o ON u.id=o.user_id WHERE o.total>100 ORDER BY o.total DESC
OutputSELECT u.id, u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id WHERE o.total > 100 ORDER BY o.total DESC

Minify SQL

InputSELECT * FROM users WHERE active = true
OutputSELECT * FROM users WHERE active = true

Frequently Asked Questions

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), PL/SQL, SQLite, and MariaDB. Select the correct dialect for best results — some keywords and syntax differ between databases.

Does the formatter validate SQL syntax?

No. The formatter reformats the text structure but does not check if the SQL is valid. Syntax errors in the original query will still be present after formatting.

Can I format stored procedures?

Yes. The formatter handles stored procedures, functions, and complex queries including CTEs, subqueries, and window functions.