SQL Formatter

Format and beautify SQL queries with proper indentation, line breaks, and keyword capitalization. This tool makes SQL queries more readable and easier to maintain. Supports various SQL dialects including MySQL, PostgreSQL, and SQL Server.

When to use this tool

You are reviewing long SQL queries and need readability.

You want consistent formatting before sharing or committing.

Examples

Format a compact SELECT query

Input

select id,name from users where active=true order by created_at desc

Output

SELECT
  id,
  name
FROM users
WHERE active = true
ORDER BY created_at DESC

Formatted SQL is easier to review in pull requests and query consoles.

Developer use cases

Format complex joins and subqueries for code review.

Standardize SQL used in reports and dashboards.

Common mistakes to avoid

Formatting queries without selecting the correct dialect.

Assuming formatting will optimize query performance.

Format and behavior notes

Formatting changes whitespace and capitalization, not query behavior.

Review dialect-specific syntax if your query uses vendor extensions.

Frequently Asked Questions

How do I format SQL?

Paste your SQL query into the editor and click Format. The query will be automatically formatted with proper indentation and line breaks.

What SQL dialects are supported?

The tool supports standard SQL and common dialects including MySQL, PostgreSQL, SQL Server, and SQLite.

Can I customize the formatting?

Yes, you can choose indentation size, keyword capitalization (uppercase/lowercase), and line break preferences.