Development & CodeLive🔒 Private

SQL Formatter

Format and indent SQL queries instantly. Free online SQL formatter — supports SELECT, JOIN, and DDL statements. No signup, 100% private browser tool.

How it works

The SQL Formatter takes raw, inline, or minified SQL queries and reformats them with consistent indentation, capitalized keywords, aligned columns, and line breaks — making complex queries immediately comprehensible.

SQL written quickly or extracted from logs or ORM output is hard to read. A SELECT with 15 columns, 4 JOINs, a nested subquery, and a GROUP BY with HAVING clause becomes a single-line wall of text. The SQL Formatter restructures it so every clause stands out, every JOIN condition is visible, and the query logic is obvious.

How to use it: paste any SQL statement — SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, ALTER, subqueries, CTEs (WITH clauses), or window functions. Choose your SQL dialect (Standard, MySQL, PostgreSQL, T-SQL/SQL Server, Oracle, BigQuery). The formatter capitalizes all SQL keywords, places each major clause on its own line, indents SELECT column lists, aligns JOIN … ON conditions, and formats subqueries with extra indentation.

Formatting decisions: keywords are uppercased (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT). Each top-level clause starts on a new line. SELECT columns are placed one per line with alignment. JOIN conditions are indented under the JOIN keyword. Nested subqueries are indented one additional level.

Use cases: reading ORM-generated queries in logs, preparing SQL for code review, debugging a complex query by making its structure visible, documenting stored procedures, and sharing queries in Slack or documentation where unformatted SQL is unreadable.

Frequently Asked Questions

Which SQL dialects are supported?
Standard SQL, MySQL, PostgreSQL, T-SQL (SQL Server / Azure SQL), Oracle PL/SQL, SQLite, MariaDB, and BigQuery SQL are all supported. Dialect-specific syntax and keywords are handled correctly for each.
Does it handle CTEs (WITH clauses)?
Yes. Common Table Expressions using WITH ... AS (...) are formatted with each CTE on its own indented block, and the final SELECT reads cleanly from them.
Can it format stored procedures?
Yes. CREATE PROCEDURE, BEGIN...END blocks, IF...ELSE, WHILE loops, and DECLARE statements in T-SQL and PL/SQL are formatted with consistent indentation.
Does formatting change query behavior?
No. SQL parsers treat whitespace (spaces, tabs, newlines) outside string literals and identifiers as insignificant. Formatted and original SQL are executed identically.