SQL Formatter
This free SQL formatter indents and cases your query in the browser, detecting whether it is MySQL, PostgreSQL, T-SQL or Oracle from the syntax itself. It also reads the query for danger: a DELETE or UPDATE with no WHERE clause, a TRUNCATE or a DROP, each flagged before you run it anywhere.
What does this formatter do?
It lays out your SQL so a person can read it, and then does something a formatter usually does not: it reads the query back to you for danger.
- Warns before you run it. A
DELETEorUPDATEwith noWHERE, aTRUNCATE, aDROP. Each one flagged with which statement it is in. - Detects the dialect from the syntax. Backticks mean MySQL, square brackets and
TOPmean SQL Server,$$and::mean PostgreSQL,DUALandNVLmean Oracle. The detected dialect is named on screen, not assumed silently. - Style you control: keyword case, indent size, and commas leading or trailing.
- Nothing leaves your browser, which matters because real queries carry real table and column names.
- Copy or download the complete formatted query as a
.sqlfile.
The warning that justifies the page
A missing WHERE on an UPDATE or DELETE is one of the most common production incidents there is. The statement is valid, it runs instantly, and it touches every row.
| Statement | What it does without a WHERE |
|---|---|
DELETE FROM orders | Empties the table |
UPDATE users SET active = 0 | Rewrites every row |
TRUNCATE TABLE logs | Empties the table, usually without a rollback |
Database clients like DataGrip and DBCode already warn you, and MySQL has a safe-updates mode. All of those protect you at the moment you execute. A formatter is often where a query is first read, reviewed, or pasted from somewhere else, and nothing warns you there. So this page does.
One detail that matters: the check looks at the top level of each statement. A WHERE that only exists inside a subquery does not make an UPDATE safe, and that case is still flagged.
Why the dialect matters
SQL dialects disagree about syntax, and a formatter that guesses wrong can break a statement apart rather than tidy it:
| Dialect | Syntax that only it uses |
|---|---|
| MySQL | Backtick identifiers: `order` |
| SQL Server | Bracket identifiers: [dbo].[Order Details], TOP 10, @variables |
| PostgreSQL | Dollar quoting $$…$$, the :: cast, JSON operators like ->> |
| Oracle | FROM DUAL, NVL(), ROWNUM |
Rather than making you pick from a dropdown and hoping, this page reads those signals and tells you what it found. Override it whenever the guess is wrong.
What this tool does not do
- It does not run anything. There is no database connection, so it cannot tell you whether a query works, is fast, or returns what you expect.
- It does not convert between dialects. Turning MySQL into PostgreSQL means rewriting functions, types and syntax. That is a different and much larger tool.
- The safety check is text analysis, not a guarantee. It reads statements after stripping comments and string contents, which prevents false alarms, but a query built dynamically inside a stored procedure or assembled by an application can still escape it. Treat a clean result as "nothing obvious found", not as approval.
- It does not lint your SQL. No style rules, no performance advice, no naming conventions. Just formatting, dialect detection and the specific dangers above.
- It does not validate syntax. Badly broken SQL may format oddly rather than produce a clear error, because the formatter works on whitespace, not on meaning.
Is my query private?
Yes. The formatting runs through a library loaded into your browser, and the dialect detection and safety checks are our own code running on the same page. No network request carries your SQL anywhere, nothing is logged or stored, and closing the tab clears it. Real queries tend to contain production table names, column names and sometimes values, which is exactly why this one stays on your device.
Frequently asked questions
What happens if I run a DELETE without a WHERE clause?
Every row in the table is removed in one statement. The same applies to an UPDATE without WHERE, which rewrites every row. Database clients warn you at execution time, but a formatter is where many people look at a query first, so the warning appears here too.
How does it know which SQL dialect I pasted?
By reading syntax that only exists in one of them: backticks point to MySQL, square brackets and TOP to SQL Server, dollar quoting and the double-colon cast to PostgreSQL, DUAL and NVL to Oracle. The detected dialect is named on screen and you can override it.
Why does picking the wrong dialect matter?
Because each dialect has syntax the others do not understand. A formatter reading MySQL backticks as generic SQL, or SQL Server brackets as something else, can break a statement apart. Naming the dialect it detected means you can see the assumption instead of guessing at the output.
Does it change my query?
Only its whitespace, line breaks and keyword casing. Identifiers, string literals, comments and operators are preserved exactly, including doubled quotes inside strings and JSON extraction operators. The result is the same query you pasted, laid out so that a person can actually read it.
Is my SQL sent to a server?
No. Formatting and the safety checks run in your browser, so the query never leaves your device. Nothing is uploaded, logged or stored. That matters more than usual here, because real queries often contain table names, column names and values from a production system.
Can it tell me whether my query is correct?
No. It formats and flags a few specific dangers, but it does not connect to a database, check that your tables exist, validate syntax against a real engine or predict what a query returns. A query can format beautifully and still be wrong or slow.
Why does it flag SELECT star?
Because it returns every column, including ones added to the table later, which can quietly change what an application receives after a migration. It is a note rather than a danger, since plenty of queries use it deliberately during exploration and debugging.
Does it detect a dangerous query hidden inside a comment or a string?
It ignores both, because comments and the contents of string literals are removed before anything is analysed. A DELETE written inside quotes, or after two dashes, does not raise a false alarm. Only statements that would really run are checked for danger.
Can it convert between SQL dialects?
No. Converting MySQL to PostgreSQL means rewriting functions, data types and syntax rather than reformatting whitespace, and it is a much larger problem. This page formats the dialect you already have, and tells you which one it believes that is.
Can I save the formatted query?
Yes. Copy puts the query on your clipboard and Download saves it as a .sql file. Both give you the complete formatted output, which matters for long migration scripts where the view on screen only shows part of what you pasted in.
Related tools
DeveloperJSON FormatterFormat, beautify, and validate JSON right in your browser.- DeveloperCSV to JSON ConverterTypes decided per column, so ZIP codes keep their zeros.
- DeveloperRegex TesterTest a regular expression live and see what every part does.
- DeveloperText Diff CheckerCompare two texts and see exactly which words changed.
DeveloperToken CounterCount tokens exactly, check the context window, estimate the cost.
Rate SQL Formatter & help shape it
This tool is free and still growing. Tell us what works, what you would change, and what is missing. Your feedback is what decides what we build next.
Last updated: September 19, 2026