SQL Formatter

Format SQL queries with proper indentation, uppercase keywords, and line breaks at clause boundaries. Supports Standard SQL, PostgreSQL, MySQL, MariaDB, T-SQL, PL/SQL, BigQuery, and Snowflake dialects. Runs entirely in your browser.

How to use the SQL Formatter

Paste SQL, pick the dialect (use Standard if unsure), and click Format. The output places each major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING) on its own line, indents subqueries, and aligns column lists. Minify produces a single-line version for embedding in code.

Why formatting SQL matters

Unformatted SQL is hard to read in code review and harder to debug. A 200-character single-line query hides errors that a properly-indented version makes obvious. Common patterns where formatting saves time: missing comma in a column list, mismatched parentheses in nested subqueries, wrong join order, accidental Cartesian product from a forgotten ON clause.

Dialect matters because SQL implementations diverge in subtle ways. PostgreSQL accepts DISTINCT ON; MySQL doesn't. T-SQL uses TOP instead of LIMIT. BigQuery requires backticks around fully-qualified table names. Picking the right dialect makes the formatter preserve and align dialect-specific keywords correctly.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, PostgreSQL, MySQL, MariaDB, T-SQL, PL/SQL, BigQuery and Snowflake. Picking the right dialect improves keyword and function handling.

Does formatting change what my query does?

No. It only changes indentation, casing and line breaks. The statement is semantically identical after formatting.

Will it format queries with parameters or placeholders?

Yes. Placeholders such as a question mark, numbered and named binds are preserved as-is, so you can format parameterized queries safely.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: