Skip to content
← Home
🔒 Runs in your browser 🚫 No data uploaded ✓ Free, no login

SQL Formatter + Explainer + Complexity Meter

Paste or drop any SQL query to format it into clean, readable code, get a plain English explanation with extracted facts, and see a complexity score with a detailed breakdown — all in one tool. Supports Generic SQL, PostgreSQL, MySQL, SQL Server, and SQLite. Everything runs entirely in your browser. No server, no uploads, no AI — pure structural analysis powered by JavaScript.

Drop .sql or .txt file here
Supports .sql and .txt files Browse files

Formatted SQL


      

Plain English Explanation

Summary

Breakdown

Extracted Facts

Complexity Score

Errors & Warnings

    What This Tool Does

    Formats messy SQL into clean, readable code and explains every clause in plain English — in a single step — processed in your browser without uploading anything.

    Who This Is For

    Example: Input: A minified 5-table JOIN query from a legacy codebase → Output: Formatted, indented SQL plus a plain-English clause-by-clause explanation: "Joins the orders table to users on user_id, filters for completed orders in the last 30 days, groups by region, and returns the count per region"

    How the SQL Formatter + Explainer Works

    This tool combines three functions into a single interface. The formatter uses the sql-formatter library to beautify your SQL with consistent indentation, keyword casing, and clause separation. The explainer parses the query structure using an AST parser with regex fallback and generates a plain English summary plus a structured breakdown of every clause. The complexity meter scores the query from 0 to 100 based on structural elements like joins, subqueries, window functions, grouping, and filter count.

    Supported Dialects

    Select your target dialect from the dropdown to get the most accurate formatting and parsing. Supported dialects include Generic SQL (ANSI), PostgreSQL, MySQL, SQL Server (T-SQL), and SQLite. If the AST parser encounters dialect-specific syntax it cannot handle, it falls back to regex-based heuristic analysis so you still get useful results.

    Understanding the Complexity Score

    The complexity score is calculated from the structural elements of your query. Each element contributes a weighted number of points, capped to prevent runaway scores. Tables contribute up to 20 points (5 per table), joins up to 30 (10 each), subqueries up to 24 (12 each), GROUP BY adds 10, window functions 15, and filters up to 10 (2 each). A simple single-table SELECT scores under 15. A multi-join report with aggregation typically scores 30–50. Complex ETL or analytics queries with CTEs, window functions, and nested subqueries legitimately score 60 and above.

    Input Methods

    You can paste SQL directly into the editor or switch to the Upload tab and drag-and-drop a .sql or .txt file. Files are read locally using the browser's FileReader API — nothing is uploaded to any server. The file name and size are displayed after loading.

    Error Handling

    If the parser cannot fully parse your SQL, the Errors tab appears with a friendly message, the original parser error (collapsed by default), and actionable tips such as checking for missing table names after FROM, unclosed quotes, or unsupported dialect syntax. Even when parsing fails, the tool still provides a best-effort explanation and complexity score using regex-based extraction.

    Privacy

    Your SQL never leaves your browser

    All formatting, parsing, explanation, and scoring happen entirely in JavaScript in your browser. There are no network calls, no server-side processing, and no data storage. This tool works fully offline once loaded.

    Frequently Asked Questions

    Does formatting change how my SQL runs?

    No. SQL is whitespace-insensitive. The database engine generates the same execution plan regardless of formatting. Formatting only affects human readability.

    Can I format and explain multiple statements at once?

    The formatter handles multiple semicolon-separated statements. The explainer and complexity meter analyze the first statement in a multi-statement input. For best results, analyze one statement at a time.

    What is the difference between this tool and the standalone formatter or explainer?

    This tool combines formatting, explanation, and complexity scoring into a single interface with tabbed output. The standalone SQL Formatter and SQL Query Explainer are also available if you prefer a focused single-purpose tool.

    Related Guides & Tutorials

    Related SQL Tools

    Editorial Policy