What the formatter does
- Starts each main clause on its own line:
SELECT,FROM,WHERE,GROUP BY,HAVING,ORDER BY,LIMIT,INSERT INTO,VALUES,UPDATE,SET,RETURNING,WITH,UNION. - Puts each selected column, each
JOINand eachAND/ORcondition on its own line, and indents subqueries and CTEs one level deeper. - Leaves strings, quoted names and comments exactly as typed. It changes layout and keyword case only, never the meaning of the query.
- Minify removes comments and line breaks and keeps one space where SQL needs it. MySQL
/*! … */and optimizer/*+ … */hint comments are kept because they change behaviour.
Why the dialect matters
The dialect only changes how quotes and comments are read, so the formatter never splits a quoted name or string:
| Dialect | Quoted names | Worth knowing |
|---|---|---|
| Standard SQL / PostgreSQL | "order" | PostgreSQL folds unquoted names to lower case, so "Users" and Users are different tables. Dollar-quoted bodies ($$ … $$) and casts (::numeric) are kept intact. |
| MySQL / MariaDB | `order` | Double quotes are strings unless the ANSI_QUOTES SQL mode is on; # starts a comment. |
| SQL Server (T-SQL) | [order] or "order" | Double-quoted names need QUOTED_IDENTIFIER on (the default for most connections). Uses TOP or OFFSET … FETCH instead of LIMIT. |
| SQLite | "order", also [order] and `order` | Accepts the other databases' quote styles for compatibility. |
Your SQL stays on your machine
The formatter is plain JavaScript in this page. Queries often contain table names, customer IDs or emails, so nothing is sent to a server; you can disconnect from the internet after the page loads and it still works.
Related: JSON formatter · XML formatter · diff checker · Postgres and Supabase security checks
Sources
- PostgreSQL docs: Lexical structure (identifiers, constants, dollar quoting): www.postgresql.org/docs/current/sql-syntax-lexical.html
- MySQL docs: Schema object names (identifier quoting): dev.mysql.com/doc/refman/8.4/en/identifiers.html
- Microsoft Learn: Database identifiers (SQL Server): learn.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers
- SQLite docs: SQL keywords (quoting): www.sqlite.org/lang_keywords.html