SQL Query Formatter

Turn messy SQL into clean, readable queries — or minify to one line

Input

Formatted output

Nothing you paste here is ever uploaded — formatting happens entirely in your browser via the sql-formatter library.

About this tool

This reformats a wall of SQL into properly indented, keyword-aligned queries using the sql-formatter library, the same parser-based approach used in many IDEs — it's not just inserting line breaks on commas. Because dialects differ in quoting rules and syntax extensions (MySQL's backticks, Postgres's double-quoted identifiers, SQL Server's bracket notation, and so on), you pick a target dialect so the output matches what your database actually expects. It can also run the reverse operation and collapse a query down to a single minified line.

Does formatting change what my query actually does?

No — formatting only changes whitespace, indentation, and keyword casing. The parsed structure of the query (clauses, conditions, joins) stays exactly the same, so the SQL executes identically before and after.

Why does it ask me to pick a SQL dialect before formatting?

Different database systems have their own quoting conventions and syntax extensions — MySQL, PostgreSQL, and SQL Server don't all parse identifiers or certain functions the same way. Selecting the right dialect makes sure the formatter parses your specific syntax correctly instead of guessing.

Can this also shrink a query down instead of expanding it?

Yes — there's a minify mode that strips the formatting back out and compresses the query onto a single line, useful when you need to paste SQL somewhere space-constrained, like a URL parameter or a config value.