SQL Formatter
Format SQL with dialect-aware keywords, or minify it to one line
About this tool
Paste a query fresh out of a log file, an ORM debug dump or a colleague's one-liner, and this formatter breaks it into readable clauses with consistent indentation. Six dialects are supported — standard SQL, PostgreSQL, MySQL, SQLite, SQL Server and BigQuery — so dialect-specific syntax like TOP, backtick identifiers or array types formats correctly instead of tripping the parser.
Keyword casing is configurable: UPPERCASE for the classic look, lowercase if your team prefers it, or leave the original untouched. The minify mode does the reverse — it collapses a formatted query to a single line, stripping comments while leaving string literals byte-for-byte intact, which is what you want before pasting SQL into a JSON config or a CLI flag.
Queries often contain table names, customer data in literals, or infrastructure hints. Formatting runs entirely in your browser, so none of that reaches a server.
Frequently asked questions
- Which SQL dialect should I pick?
- The one your database speaks — it changes how identifiers, string quoting and dialect keywords are parsed. If you just need generic tidying, standard SQL handles the common core. A parse error on valid-for-your-database syntax is usually a sign to switch dialects.
- Does formatting change what the query does?
- No. Formatting only moves whitespace and, if enabled, changes keyword casing — identifiers and literals keep their exact bytes. SQL keywords are case-insensitive in every supported dialect, so SELECT and select are the same statement.
- Can I format multiple statements at once?
- Yes — paste a whole script and each ;-terminated statement is formatted in sequence with a blank line between them.
- What exactly does minify remove?
- Line comments (--) and block comments (/* */) are dropped, runs of whitespace collapse to single spaces, and spaces around commas and parentheses are removed. Text inside single quotes, double quotes and backticks is never touched, including doubled-quote escapes.