SQL Query Formatter
Enter SQL and click Format & Analyze to see results
Multi-Dialect Formatting
Beautiful formatting for MySQL, PostgreSQL, T-SQL, Oracle, and SQLite with configurable indentation and keyword case.
Human Explanation
Understand complex queries with step-by-step breakdowns in logical execution order — no AI required.
Risk & Performance
Catch dangerous queries (DELETE without WHERE) and performance issues (SELECT *, leading wildcard) before they hit production.
About the SQL Suite
The SQL Suite formats, explains, and risk-checks SQL across MySQL, PostgreSQL, T-SQL (SQL Server), Oracle PL/SQL, and SQLite dialects — entirely in your browser via the `sql-formatter` and `node-sql-parser` libraries. Paste a query (your ORM-generated mess, an audit-log entry, a vendor support snippet) and get back idiomatic indentation and keyword case, a step-by-step explanation, and warnings for risky patterns. When the parser cannot read the query, it shows the parse error. Nothing is sent to our servers or analytics, but the query is saved in the page address, so avoid pasting real customer data.
Updated: May 8, 2026
Related Tools
How to use the SQL suite
- Paste your SQL into the input area and pick the dialect from the dropdown (MySQL is the default). The dialect is not auto-detected.
- Click Format & Analyze to apply the dialect-aware pretty-printer. Indentation defaults to 2 spaces and can be set to tabs or 4 spaces.
- Choose the keyword case (UPPER, lower, or preserve) and trailing or leading commas, then copy the formatted SQL or download it as a `.sql` file.
- Turn on Minify to collapse whitespace into a single line — useful when embedding a query in a one-liner test or a JSON config. String literals, quoted identifiers, and comments are kept as-is, and a `--` comment keeps its line break so it cannot comment out the code after it.
- Open the Explained tab for a clause-by-clause walkthrough from node-sql-parser, or the Risks tab for warnings such as DELETE or UPDATE without WHERE, DROP TABLE, SELECT *, a missing LIMIT, nested subqueries, and leading-wildcard LIKE. If the query does not parse, the Explained tab shows the parser error.
- Use the Share button to copy a link that includes the query (long queries are compressed with lz-string) — convenient for filing reproducible SQL bug reports in tickets.
Common use cases
- Code review prep. Paste an unformatted SQL diff so reviewers can read the actual query structure instead of the original 200-character single-line ORM output.
- Debugging slow-query logs. Most database slow-query logs emit minified SQL with parameters interpolated. Format it here to see the JOIN graph, subqueries, and WHERE clause structure at a glance.
- ORM-generated SQL inspection. SQLAlchemy `echo=True`, ActiveRecord `to_sql`, Prisma logs, and the Spring Data Hibernate dialect all output one-liner SQL — formatting reveals what your ORM is actually asking the database to do.
- Ad-hoc query authoring. Sketch a query, format it as you go, copy into a database client (psql, DBeaver, DataGrip) for execution.
- Embedding SQL in documentation. Generate readable SQL for ADRs, runbooks, README snippets — a formatted query in markdown is dramatically more reviewable than a minified blob.
Privacy and security
Formatting and validation run via `sql-formatter` and `node-sql-parser` bundled into the page — both pure JavaScript, and no request carries your query. Nothing is sent to our servers or analytics. The query and dialect are saved in the page address as you type, though, so scripts on the page, including ads, can read it, and ad requests may send the page address to Google. It is also sent to our CDN when you reload, included in links you share, and kept in browser history. Long queries are compressed with lz-string, which is not encryption — anyone with the link can read the query. Avoid pasting real customer data or inlined secrets.
Tips and pitfalls
- Pick the right dialect. PostgreSQL `LATERAL` and SQL Server `CROSS APPLY` are functionally similar but parse differently; `RETURNING` is PostgreSQL/Oracle/SQLite, not MySQL/SQL Server; `OFFSET ... FETCH FIRST` is standard, `LIMIT n` is dialect-specific. The tool does not detect the dialect, so when the formatter produces unexpected output, check the dialect setting.
- Comments are preserved on Format and Minify. `-- single-line` and `/* block */` comments survive formatting — useful for keeping inline review notes inside the query.
- CTEs format cleanly. Common Table Expressions (`WITH foo AS (...)`) get aligned indentation and column-list breaks; nested CTEs are still readable past 3-4 levels.
- Identifier quoting varies. Backticks (`` `table` ``) for MySQL, double quotes (`"table"`) for PostgreSQL/SQL standard, square brackets (`[table]`) for SQL Server. The formatter preserves the original quoting style.
- Parameter placeholders differ. `?` (MySQL/SQLite/JDBC), `$1, $2, ...` (PostgreSQL), `:name` (Oracle/Hibernate), `@name` (SQL Server / .NET). The validator accepts all of them; check that the dialect setting matches the placeholder convention.
Frequently Asked Questions
- Which SQL dialects are supported?
- MySQL, PostgreSQL, T-SQL (MS SQL Server), Oracle PL/SQL, and SQLite. Choose the dialect from the dropdown; it is not auto-detected. The Explained and Risks tabs parse Oracle queries with the MySQL grammar, so Oracle-only syntax may not parse there.
- Does it preserve comments?
- Yes. Both `-- single-line` and `/* block */` comments survive the formatter. Inline review notes, license headers, and `EXPLAIN`-output annotations stay intact.
- How are CTEs formatted?
- WITH clauses get their own indentation level; column lists inside the CTE wrap at the comma boundary. Nested CTEs (a `WITH` inside another CTE body) format cleanly through 3-4 nesting levels; deeper nesting becomes hard to read regardless of formatter — consider refactoring to subqueries or temporary tables.
- Can I validate syntax beyond just formatting?
- Partly. When you click Format & Analyze, the parser (node-sql-parser) reads the query for the Explained and Risks tabs, and the Explained tab shows a parse error for missing keywords, unbalanced parentheses, or mistyped statement structure. It does not check semantics: an invalid table name, a column reference to a column that does not exist, or a type mismatch will pass syntax validation and only fail at execution time.
- Does it format DDL statements (CREATE / ALTER / DROP)?
- Yes — schema migrations format the same way as queries. CREATE TABLE column definitions get aligned data types and constraints; CREATE INDEX clauses get proper line breaks; ALTER TABLE chains stay readable.
- How is this different from sqlfluff?
- sqlfluff is a full SQL linter — it enforces project-specific style rules (capitalization, alias requirements, JOIN ordering, etc.). This tool is a formatter — it produces idiomatic dialect-aware indentation but does not enforce a custom rule set. Use this for ad-hoc cleanup, sqlfluff for CI lint enforcement.
- Are stored procedures supported?
- Partially. Procedure bodies that contain only standard SQL format cleanly; procedure bodies with PL/pgSQL, T-SQL, or PL/SQL control-flow constructs (BEGIN ... END, IF / WHILE, exception blocks) format as one statement and may not pretty-print individual control structures.
- Is multi-statement SQL handled?
- Yes. Statements separated by semicolons are formatted independently and re-joined with consistent spacing. Useful when you have a setup-query / actual-query pair.
- Is the input ever uploaded?
- Not for processing. Both formatting (sql-formatter) and parsing (node-sql-parser) run as compiled-to-JavaScript libraries inside your browser tab. Nothing is sent to our servers or analytics. The query is saved in the page address query string as you type (lz-string compressed when long, not encrypted), so it is sent to our CDN when you reload and is included when you share the link.