SQL Formatter
Make long SQL queries readable with clean indentation and uppercase keywords.
How to use: Paste your SQL, choose the indent and keyword case, then press Format. Press Minify to squash it onto one line.
How to use the SQL Formatter
SQL generated by applications, copied from logs or written in a hurry often ends up as one enormous line. Formatting it reveals the structure of the query, making it far easier to spot a missing join condition, a wrong filter or an inefficient subquery.
Paste one or more statements and press Format. Major clauses such as SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT start on new lines. Each selected column goes on its own line, AND and OR conditions are indented under WHERE and ON, and every JOIN begins a new line. Subqueries in parentheses are indented one level deeper and closed on their own line.
Keywords can be converted to uppercase, a common convention that separates SQL words from table and column names, or left as typed. Strings in single quotes, quoted identifiers and comments are never changed. Minify does the reverse, removing comments and line breaks so a query fits on one line for code or config files.
The formatter is dialect-friendly and works with MySQL, PostgreSQL, SQLite, SQL Server and most other databases because it only rearranges whitespace and keyword case. Your queries are processed locally, which matters when they contain table names or data from production systems.
Frequently asked questions
Which SQL dialects are supported?
Standard SQL and the common syntax of MySQL, PostgreSQL, SQLite, SQL Server and Oracle. Unusual vendor extensions are kept as they are.
Does formatting change the query?
No. Only whitespace and, optionally, keyword case change. Strings and identifiers stay exactly the same.
Is my SQL sent to a server?
No. Formatting happens entirely in your browser.