🌐 EN

πŸ—„οΈ SQL Formatter

Line-break and indent SQL queries by clause for readability, or minify them to a single line for logging/storage. Uppercasing keywords is optional.

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

Line breaks are inserted before major clauses (SELECT/FROM/WHERE/JOIN variants/GROUP BY/ORDER BY/HAVING/LIMIT, etc.), and AND/OR are indented one level to set conditions apart. Comma-separated column lists each get their own line, and parenthesized content (subqueries, etc.) gets an extra indent level. This is a token-based formatter, not a full SQL parser β€” deeply nested subqueries or vendor-specific syntax may need a quick manual touch-up after formatting.

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.)?
It's a token-based formatter recognizing common keywords, not a full parser. It handles SELECT/INSERT/UPDATE/DELETE/CREATE TABLE and common join syntax well, but vendor-specific extensions may not follow the exact formatting rules.
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.