SQL Formatter / Beautifier
Processed Client SideBeautify or minify SQL queries. Detects the dialect, indents clauses and joins, and normalises keyword case — all in your browser.
Bookmark this tool now — skip the search next time you need it.
About SQL Formatter / Beautifier
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The SQL Formatter takes a query that arrived as one unreadable line — out of a slow-query log, an ORM, or a bug report — and lays it out so you can follow it. Clauses start their own lines, each join sits above its own ON predicate, boolean conditions stack under WHERE, and subqueries indent inside their parentheses. Minify does the reverse, squeezing a statement back onto one line for a config file or a connection string. It works out the dialect from the markers in your SQL and says what it decided, so you can overrule it. Everything runs in your browser.
Key features
- Beautify and minify from one toggle, re-running on every keystroke
- Automatic dialect detection for MySQL, PostgreSQL, SQLite, SQL Server and Oracle, shown beside the result
- Clause-aware layout: SELECT, FROM, WHERE, GROUP BY, joins, CTEs and set operators each begin their own line
- AND and OR lead their own line under WHERE and ON, while a BETWEEN keeps its AND
- Lists stay on one line while they fit, break one item per line, or never break in Compact mode
- One column definition per line in CREATE TABLE, one row tuple per line in a multi-row INSERT
- CASE stays inline when short and indents its WHEN branches when long
- Keyword case set to UPPER, lower, or left as written — quoted identifiers are never re-cased
- Comments kept on the line they described, and optimizer hints survive minification
- A statistics row reporting statements, tables referenced, joins, subqueries and comments
- Syntax highlighting in both panes, copy to clipboard, download as .sql, and nothing uploaded
How to use it
- Paste your SQL into the left pane, replacing the sample.
- Leave Dialect on Auto detect, or pick one if your snippet has no dialect-specific syntax.
- Choose Beautify to expand the query, or Minify to squeeze it onto one line.
- For Beautify, set the indentation, keyword case, and how eagerly lists break.
- Read the result on the right, and the badges under it for the dialect and statistics.
- Copy the output, or download it as a .sql file.
Tips & common mistakes
- The dialect changes how your SQL is read, not how it is laid out: whether # opens a comment, whether [name] is an identifier, whether $$ quotes a body. The indentation rules are identical for every dialect.
- Auto detect scores dialect markers, and only inside real code — AUTO_INCREMENT sitting in a string literal is ignored. A query with no markers says so rather than guessing, and picking a dialect yourself always wins.
- Minify removes whitespace and comments and nothing else. It does not rename anything, reorder joins, or rewrite your query into a faster one, so the saving is in bytes, not execution time.
- Hints survive minification. A comment opening with a plus is an optimizer hint, and one opening with an exclamation mark is version-gated MySQL that executes — dropping either changes what the database does.
- Re-casing keywords is safe for unquoted names, which these engines case-fold anyway. Anything inside backticks, double quotes, or brackets passes through character for character.
- Columns are deliberately not aligned into a second column: alignment depends on the width of the keyword before it, so it breaks under lower-case keywords or tabs and re-flows on every rename.
- This is a formatter, not a validator: broken SQL still formats, and output that indents unexpectedly usually points straight at a parenthesis you forgot to close.
- The table list is a token heuristic, not name resolution: it reads the identifier after FROM, a JOIN, INSERT INTO, UPDATE or DELETE FROM and drops CTE names.