SQL Formatter | Format Queries and Keywords

Format SELECT queries, joins, subqueries, WHERE clauses, aliases, and keyword casing for debugging or code review.

SQL Query Input
Formatted SQL Query

Make SQL Queries Easier to Read

Format SELECT statements, JOINs, WHERE filters, GROUP BY clauses, ORDER BY clauses, subqueries, aliases, and keyword casing for review.

Review Dialect-Specific Syntax

Formatted SQL can still behave differently in MySQL, PostgreSQL, SQL Server, SQLite, or Oracle. Check functions, quotes, date syntax, and limit clauses before running a query.

Use Before Debugging or Sharing SQL

Clean indentation helps teammates spot missing joins, nested conditions, confusing aliases, and clause order problems before a query reaches production data.

About This Tool

SQL Formatter takes minified or poorly formatted SQL queries and outputs them with consistent indentation, keyword capitalisation, and clause alignment. Readable SQL is easier to review, debug, and share with colleagues.

When to Use It

Use this when debugging a complex multi-join query, when reviewing SQL from an ORM that generates minified output, or when preparing a query for documentation or a code review.

How to Use

  1. Paste your SQL query into the input area.
  2. Click Format to apply indentation and keyword capitalisation.
  3. Review the structured output.
  4. Copy the formatted SQL.

Frequently Asked Questions

Does it support all SQL dialects?

The formatter handles standard ANSI SQL and common dialects including MySQL, PostgreSQL, SQL Server, and SQLite syntax.

Can it also minify SQL?

Yes. A minify option removes whitespace and comments to produce compact SQL for use in application code.

Does it validate the query?

Basic syntax errors are highlighted. Full query validation including table and column existence requires a live database connection.