SQL Query Explainer — Understand Any SQL Query
Paste any SQL query and get a plain English summary, a structured breakdown of every clause, and a complexity score — all generated instantly from the query's structure, with no AI involved. The explainer identifies tables, columns, join conditions, filters, aggregations, sorting, and limiting. It then scores the query's complexity based on the number of joins, subqueries, window functions, and other structural elements. Use it to understand inherited queries, document existing SQL, or learn how complex queries are structured.
What This Tool Does
Analyzes a SQL query and produces a plain-English explanation of what each clause does — identifying table relationships, filters, aggregations, and subqueries — in your browser.
Who This Is For
- SQL beginners trying to understand queries written by senior developers
- Data analysts onboarding to a new codebase who need to quickly understand existing queries
- Technical writers and documentation teams who need plain-English descriptions of complex SQL
- Developers reviewing legacy code before modifying queries that haven't been touched in years
Example: Input: SELECT u.name, COUNT(o.id) FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id HAVING COUNT(o.id) > 5 → Output: "Returns the name of each user who has placed more than 5 orders, including a count of their orders. Users with no orders are excluded by the HAVING clause."
What Does the Explainer Show?
The explainer generates three outputs from your SQL:
1. Plain English Summary — A natural-language sentence describing what the query does. For example: "This query selects customer names and order totals from the customers and orders tables, joins them on customer_id, filters to paid orders, groups results by customer, and returns the top 10 by revenue."
2. Structured Breakdown — A card-based view showing the query type, tables used, columns selected, join conditions, filters, aggregations, sorting, and limiting. Each element is displayed in its own card for quick scanning.
3. Complexity Score — A numeric score from 0 to 100 with a label (Simple, Moderate, Complex, or Advanced) and a list of reasons explaining the score. A single-table SELECT with no joins scores low. A multi-CTE query with window functions, subqueries, and HAVING clauses scores high.
How the Complexity Score Works
The scoring algorithm adds points for structural complexity:
- +12 per JOIN — Each join increases the number of tables the reader must hold in memory
- +15 per subquery — Nested queries require understanding the inner query before the outer
- +12 per window function — OVER() clauses add a partitioning and ordering layer
- +10 per UNION — Combining result sets multiplies the mental model
- +8 for GROUP BY — Aggregation changes the granularity of the result
- +8 for CTEs — Common table expressions add named intermediate results
- +5 for HAVING — Post-aggregation filtering adds another condition layer
- +3 per aggregate function — COUNT, SUM, AVG, MIN, MAX each add a calculation
- +3 for DISTINCT — Deduplication implies potential data quality considerations
The score caps at 100. Scores are labeled: Simple (0–25), Moderate (26–45), Complex (46–70), Advanced (71–100).
No AI — Pure Structural Analysis
This tool does not use any AI, machine learning, or external API. Every explanation is derived by parsing the SQL text and analyzing its clauses, keywords, and structure using JavaScript running in your browser. This means the explanations are deterministic: the same query always produces the same explanation, and no data is ever sent to any server.
Use Cases
- Understand a complex query you inherited from a previous developer
- Document existing SQL queries with plain English descriptions
- Review query complexity before sending to production
- Learn SQL by seeing how clauses map to plain language
- Audit stored procedures to understand what each query does
- Compare the complexity of different approaches to the same problem
🔒 Privacy & Security
Your SQL never leaves your browser. There is no server — all parsing, validation, formatting, and explanation happens in JavaScript running locally on your device. This means your table names, column names, query logic, and data patterns are never transmitted anywhere. You can disconnect from the internet after loading this page and the tool still works.
Frequently Asked Questions
SQL Tool Suite
Related Guides & Tutorials
SQL Validation: A Complete Guide
Learn how to validate SQL before execution across PostgreSQL, MySQL, and SQL Server.
TutorialHow to Validate SQL Queries Online
Step-by-step tutorial for catching syntax errors and dialect incompatibilities.
GuideUnderstanding SQL Queries
How query explainers parse SQL to produce summaries and complexity scores.
TutorialExplain SQL in Plain English
Step-by-step tutorial for getting plain English breakdowns of any SQL query.
GuideSQL Formatting & Complexity Scoring
How formatters, explainers, and complexity meters work together for readable SQL.
TutorialSQL Formatter + Explainer Tutorial
Step-by-step tutorial for the combined formatter, explainer, and complexity meter.
