🌐 EN

🗄️ SQL Formatter

Format generic SQL with clause-based line breaks and indentation. You can minify supported SQL to one line; minifying removes comments. Keyword capitalization is optional.

Samples

This tool formats SQL but does not validate it, confirm database-specific compatibility, or verify query meaning.

SQL is processed only on this device.

GUIDE

Learn more

01

1. Why format SQL

One-line or ORM-generated SQL becomes hard to read as joins pile up. Breaking it into clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, etc.) with consistent indentation makes it instantly clear which tables join on what condition and what the WHERE filters are — speeding up code review and debugging.

02

2. How this tool formats

The formatter starts a new line before clauses such as SELECT, FROM, WHERE, and JOIN, and indents AND and OR by one level. Comma-separated lists are placed on separate lines, and parenthesized content gets one more level of indentation. It is a token formatter, not a SQL validator or a parser for every dialect. Syntax it cannot preserve safely, such as named parameters or vendor-specific literals, produces an error. If that happens, keep the query unchanged and use the original in a SQL tool that supports that syntax.

03

3. Minify and when to use it

Minify strips comments and collapses unnecessary whitespace/line breaks into a single line. Handy for logging a query, shrinking stored-procedure/migration script size, or pasting a one-liner into another tool. Content inside string literals (quoted values) is preserved exactly, so your data values are never altered.

Frequently asked questions

Does it support every SQL dialect (MySQL, PostgreSQL, Oracle, etc.)?
No. This is not a SQL validator or a dialect-specific parser. It formats common SQL tokens and join forms, but shows an error instead of processing syntax it cannot preserve safely, including named parameters and vendor-specific literals. In that case, do not change the query; use the original with your database or a SQL tool that supports it.
Does it uppercase SQL keywords found inside strings?
No. String literals wrapped in quotes ('...', "...", `...`) are recognized separately during tokenizing and are excluded from case conversion or line-break logic.
Is my query sent to a server?
No. Both formatting and minifying happen entirely in your browser and are never sent to a server.
Can I change the indent width?
Yes — pick 2 or 4 spaces from the indent dropdown.