SQL Formatter
Format SQL queries instantly. Supports PostgreSQL, MySQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake. Free, no signup, runs in your browser.
About SQL Formatter
Paste a one-line SQL query, get a multi-line readable version. Quick formatter for the everyday “this query came out of an ORM log and I can’t read it” moment.
The output:
- One top-level clause per line (SELECT, FROM, WHERE, JOIN, GROUP BY, etc.)
- One column per line in SELECT lists
- Logical operators (AND, OR) on new lines in WHERE clauses
- Configurable indent (2 spaces / 4 spaces / tab)
- Configurable case (UPPER / lower / preserve)
- Comments preserved on their own lines
For a more complete query analysis, paste the formatted result into your database’s EXPLAIN tool. For converting between dialect-specific syntaxes (e.g. MySQL DATE_FORMAT → PostgreSQL TO_CHAR), you’d want an AI-assisted converter — outside the scope of this tool.
Free, no signup, runs entirely in your browser.
Frequently asked questions
Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake, and Redshift. The formatter recognises common keywords across all these dialects. Dialect-specific syntax (e.g. PostgreSQL's RETURNING, BigQuery's STRUCT) passes through unchanged.
It places each top-level clause (SELECT, FROM, WHERE, GROUP BY, etc.) on its own line, breaks comma-separated lists onto multiple lines, indents nested expressions, normalises whitespace, and optionally upper/lower-cases keywords. The result is readable SQL that's easier to scan, review, and version-control.
No. Only whitespace and case are modified. Identifier names, string values, and the actual SQL semantics are preserved exactly. Pass the formatted query straight back to your database and it executes identically to the original.
Style preference — the SQL standard doesn't mandate case. UPPERCASE is the traditional choice and the most-readable for many people. lowercase is increasingly common in modern style guides and matches how some codebases prefer their SQL embedded in code. 'As-is' preserves what you typed.