SQL Formatter

Format SQL queries with basic keyword highlighting style and line breaks.

Complex SQL queries written on a single line or with inconsistent indentation are difficult to review, debug, and maintain. This formatter applies standard indentation, keyword capitalisation, and logical line breaks to transform messy queries into clean, readable SQL that reveals the query's logical structure.

Your result will appear here...

How to Format SQL Queries

  1. Paste your SQL — paste a messy or minified SQL query.
  2. Click Format — the tool applies proper indentation, capitalisation, and line breaks.
  3. Review and copy — verify the formatted query and copy it into your SQL editor or documentation.

Frequently Asked Questions

Why should I format SQL queries? ▼
Formatted SQL is dramatically easier to read, debug, and maintain. Proper indentation reveals the logical structure of complex JOINs, subqueries, and WHERE clauses. It also makes code reviews faster and reduces the chance of introducing bugs when modifying queries.
Does formatting change how the SQL executes? ▼
No. SQL formatting is purely cosmetic — whitespace, indentation, and line breaks do not affect query execution or performance. The database engine ignores them. Formatting only improves human readability.
What SQL dialects are supported? ▼
The formatter handles standard SQL (ANSI), MySQL, PostgreSQL, SQLite, T-SQL (SQL Server), and Oracle syntax. The core keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) are recognised across all dialects.
Should SQL keywords be uppercase? ▼
Convention, not requirement. Most style guides recommend uppercase keywords (SELECT, FROM, WHERE) to distinguish them from table and column names. This tool uppercases keywords by default, which is the most widely adopted standard in professional SQL development.
Can this formatter handle subqueries and CTEs? ▼
Yes. The formatter properly indents subqueries (nested SELECT statements) and Common Table Expressions (WITH clauses). Complex multi-level nesting is handled with increasing indentation levels for clarity.
Is my SQL stored? ▼
No. All formatting happens in your browser. No query data is sent to any server.