What the SQL Formatter does
ToolMint's SQL Formatter turns pasted SQL into a more readable layout without executing it. Choose Standard SQL, PostgreSQL, MySQL, SQLite or SQL Server, then adjust indentation, keyword casing, comma style and line wrapping. Formatting changes presentation only; it does not validate, optimize or guarantee semantic correctness.
SQL is processed locally in the current browser tab. The tool does not upload, store or execute your query. Query text, table names, column names, values, comments, formatted output and raw errors are excluded from analytics.
What the formatter does not do
This is a conservative formatter, not a complete SQL parser. It does not connect to a database, validate syntax, optimize a query, rewrite dialects or prove that the output has the same behavior as the input. Review the formatted result and test important SQL in the intended database environment before using it.
If the input contains procedural, dialect-specific or ambiguous syntax, the tool keeps its layout conservative and displays a warning. A warning is a review prompt, not a validation failure or approval.
How to format SQL
- Paste a query into SQL query.
- Select the closest dialect.
- Choose indentation, keyword casing, comma style and line wrapping.
- Select Format SQL.
- Compare the original input with the formatted output and review any warnings.
- Copy or download
formatted.sqlonly after checking the result.
The input limit is 200,000 characters. Larger pastes are rejected with a clear message. This bound keeps browser-local formatting predictable; it is not a guarantee that every complex query will be fast.
Supported dialect choices
| Choice | Intended use | Important limitation |
|---|---|---|
| Standard SQL | Portable SQL examples and common clauses | Vendor extensions may need review |
| PostgreSQL | PostgreSQL queries and common extensions | PostgreSQL syntax is not validated |
| MySQL | MySQL queries and common extensions | MySQL syntax is not converted to another dialect |
| SQLite | SQLite queries and common pragmas | Unusual procedural or shell syntax may warn |
| SQL Server | T-SQL queries and common clauses | T-SQL batches and procedural syntax may warn |
The dialect setting guides warnings and review context. It never rewrites one database dialect into another.
Formatting options
Indentation can use two spaces, four spaces or tabs. Keyword casing can be uppercase, lowercase or preserved from the input. Commas can remain trailing or move to the beginning of the next formatted line. Line wrapping uses a practical width, with an option to disable wrapping.
These options move whitespace around recognized tokens. Strings, quoted identifiers, numeric and date-like literals, comments and semicolons remain content-bearing parts of the query.
SELECT, JOIN and filtering
Input:
select u.id,u.name from users u left join teams t on t.id=u.team_id where u.active=1 and u.name like 'select from' order by u.name limit 20 offset 5;
The formatter lays out SELECT, FROM, JOIN, ON, WHERE and ORDER BY clauses on readable lines. The string 'select from' remains a string and its words are not treated as SQL clauses.
INSERT, UPDATE and DELETE
The same conservative layout applies to data-changing statements:
insert into audit_log (user_id,action) values (42,'UPDATE');
update users set display_name='Where',updated_at='2026-09-15' where id=42;
delete from sessions where expires_at < '2026-09-15';
The formatter does not remove or rewrite values such as 'UPDATE' or date-like literals. Review data-changing queries particularly carefully before executing them.
CTEs, subqueries and expressions
Common table expressions and nested queries receive indentation when their parentheses are structurally clear:
with active_users as (select id from users where active=1) select u.id from active_users u where u.id in (select id from audit_log where action='SELECT');
Nested expressions, parentheses and operators are handled conservatively. The helper does not attempt to build a full abstract syntax tree, so complex vendor-specific expressions may produce a warning or a layout that deserves manual review.
Comments and quoted identifiers
Line comments and block comments remain comments rather than becoming markup or executable content:
select `select`, [from], "where" /* keep this review note */ from reports -- source table
where status='FROM';
Backtick identifiers, bracketed identifiers and double-quoted identifiers are preserved exactly. SQL-like words inside quoted identifiers, strings and comments do not trigger keyword formatting.
Privacy and safe output
The tool performs tokenization and layout in the browser. It does not evaluate SQL or send a request to an API. Output is rendered as escaped text, not injected HTML, so SQL comments or strings containing <script>, event-handler text or HTML-like fragments remain text.
Analytics contain only generic operation data such as the tool slug, operation, selected dialect, result status, warning presence and a coarse input-length bucket. They never contain query text, identifiers, values, comments, formatted output or raw parser errors.
Review limitations and common mistakes
- A formatted query is not necessarily valid SQL.
- Choosing PostgreSQL does not make MySQL or SQL Server syntax portable.
- Formatting does not optimize joins, indexes, predicates or execution plans.
- Procedural batches, vendor commands and ambiguous constructs may produce warnings.
- A visually attractive layout is not proof of semantic equivalence.
- Always keep the original query and test important changes in the intended database environment.
For structured data around a SQL workflow, the JSON Formatter can format JSON text, the Regex Tester can inspect regular expressions used in filters, the JSON Schema Validator can check JSON contracts, and the JSONPath Tester can query nested JSON. None of those tools validates SQL.
Sources
- PostgreSQL SQL Syntax
- MySQL Reference Manual: SQL Statements
- SQLite SQL Language
- Transact-SQL Reference
The FAQ section below is generated from the ToolMint registry so visible answers and FAQ structured data remain synchronized.