Dev / Text & Code / SQL Formatter

SQL Query Formatter — Analyze & Format SQL Queries Online

Format, minify, validate SQL · Auto-detect dialect · AI explain & optimize

💡

SQL Query Formatter goes beyond formatting — it analyzes query structure, extracts all table names with their roles (main, JOIN, subquery), counts JOINs and WHERE conditions, calculates query complexity score, and detects query type (SELECT/INSERT/UPDATE/DELETE/DDL). Perfect for query review and optimization.

or drag & drop .sql / .txt anywhere · max 5MB
Ctrl+M to cycle
Dialect
✦ AI
INPUT
Indent
Keywords
OUTPUT
Formatted SQL will appear here…
In: 0 chars · 0 lines·Out: 0 chars · 0 B·0ms
0 uses · 0 secondsmin saved

About SQL Formatter

SQL Query Formatter goes beyond formatting — it analyzes query structure, extracts all table names with their roles (main, JOIN, subquery), counts JOINs and WHERE conditions, calculates query complexity score, and detects query type (SELECT/INSERT/UPDATE/DELETE/DDL). Perfect for query review and optimization.

Frequently Asked Questions

What does the Query Stats panel show?

Query Stats shows: query type (SELECT/INSERT/UPDATE/DELETE/CTE), table count, JOIN count, WHERE clause count, subquery count, complexity rating (Simple/Moderate/Complex/Very Complex), complexity score (0-100), and boolean flags for GROUP BY, ORDER BY, LIMIT, and DISTINCT.

How is query complexity calculated?

Complexity score adds: 15 points per JOIN, 20 points per subquery, 5 points per table, 5 points per WHERE clause, 10 for GROUP BY, 10 for HAVING, 5 for DISTINCT, and 15 for CTE (WITH clause). Score 0-14 = Simple, 15-34 = Moderate, 35-59 = Complex, 60+ = Very Complex.

What does the Table Extractor show?

Table Extractor identifies all table names referenced in the query and categorizes them as: main (in FROM or INTO clause), join (in any JOIN clause), or subquery. Aliases are detected and shown alongside the table name.

Can it handle multi-query SQL files?

Yes. Paste SQL with multiple statements separated by semicolons. The tool splits them into numbered tabs showing a preview of each query. Click any tab to analyze and format that specific query.

Does it support DDL (CREATE TABLE, ALTER TABLE)?

Yes. DDL statements are recognized, formatted, and labeled as CREATE, ALTER, or DROP in the Query Stats panel. CREATE TABLE, CREATE INDEX, ALTER TABLE ADD COLUMN, and DROP TABLE are all supported.

Ctrl+Enter FormatCtrl+M Cycle ModeCtrl+L ClearCtrl+S Download .sqlCtrl+Shift+C CopyF FullscreenP Pin? Help