SQL Formatter
Formats and minifies SQL queries across 20 dialects, with configurable indentation and keyword case.
Mode
Dialect
Keyword case
Indentation
What is SQL
SQL (Structured Query Language) is the standard language for querying and manipulating relational databases. The same query can be written in very different shapes — a single line pulled from a log, from an ORM, or pasted by a colleague — and still mean exactly the same thing; formatting reorganizes that shape without changing its meaning.
SQL dialects
Every database engine (PostgreSQL, MySQL, SQL Server, Oracle, BigQuery...) extends standard SQL with its own syntax — operators, functions, and even comment forms that don't exist in the others. Picking the right dialect keeps the tool from rejecting valid syntax just because it was written for a different engine (e.g. PostgreSQL's `::` cast operator doesn't exist in standard SQL).
Format (Pretty Print)
Format reorganizes the query with consistent indentation per clause (SELECT, FROM, WHERE, JOIN...), preserving the exact same content — strings and comments are never altered. Keyword case (UPPERCASE, lowercase, or preserve as-is) and indentation size are configurable.
Minify
Minify shrinks the query to a single line, collapsing all whitespace and line breaks used only for readability — useful for pasting into code or a log. Unlike Format, Minify removes comments: a line comment (--) without its original line break would comment out the rest of the query, so keeping it would break the SQL — it's the only safe way to produce a single line.
Does this validate my query?
No — this tool formats, it doesn't validate. The library behind it sometimes trips over obvious structural errors (an unclosed parenthesis, an unterminated string) and shows where, but plenty of genuinely invalid SQL passes through without any warning, because the formatter prioritizes reorganizing whitespace, not checking meaning. Real validation would require a full parser per dialect — a separate project, out of scope for this tool.
Known limitations
Error diagnostics (when they exist) only recognize strings delimited by single/double/backtick quotes with doubling as the escape ('' ); backslash escaping, common in MySQL, isn't recognized. The `#` line comment is only treated as a comment in the MySQL family of dialects — elsewhere it's ordinary text. Multiple queries separated by `;` are formatted together, with no selector to format them one at a time.
Frequently asked questions
No. All processing happens in your browser — the SQL you paste here never travels over the internet and is never logged anywhere.
Not fully — see "Does this validate my query?", above. It formats, and as a side effect of that process it sometimes catches an obvious structural error, but that's not the same as full validation.
Standard SQL (the initial value) covers the syntax common to virtually every engine. Switch to the specific dialect (PostgreSQL, MySQL, SQL Server...) when your query uses syntax unique to that engine — e.g. PostgreSQL's `::` or MySQL/BigQuery's backticks — and Standard SQL rejects something you know is valid.
Because a line comment (--) without its original line break would comment out the rest of the query — keeping it would break the SQL, not just the aesthetics. Block comments (/* */) are removed too, so the behavior stays predictable in both cases.
Format (Pretty Print) arranges the query with indentation, for human reading. Minify shrinks it to a single line, with no comments, for pasting into code or a log — the same data, two representations.
The selected dialect may not recognize syntax specific to a different engine (e.g. PostgreSQL's `::` under the Standard SQL dialect). Switch to the correct engine's dialect — see "Which dialect should I pick?", above.
File upload accepts up to 5 MB. Pasting directly into the text field has no technical limit, but very large queries may slow the browser down.