SQL formatter
Format SQL for 18 dialects — PostgreSQL, MySQL, SQLite, T-SQL, BigQuery, Snowflake, Spark and more — with keyword case, indent style, and minify.
Added
How to use it
Paste a query or a whole script on the left; the formatted version appears on the right as you type (or press Format, Cmd/Ctrl+Enter).
-
Dialect matters: it decides which quoting, comments, operators, and keywords are recognised (
#comments in MySQL,[brackets]in T-SQL,$$blocks in PostgreSQL). -
Keywords, Functions, Data types, Identifiers change case independently, or keep it.
-
Indent style "Tabular" lines up clauses in a column; Inline width sets how long a parenthesised expression may stay on one line.
-
Minify strips comments (keeping
/! … */and/+ … */optimiser hints) and collapses whitespace outside strings. -
Use output as input lets you minify a formatted result, or reformat with other options.
Formatting uses the open-source sql-formatter library, downloaded from jsdelivr the first time you format; your SQL never leaves the page.
Sharing
Share link copies a URL that opens this tool exactly as you have it. Hand-written links work too: ?dialect=mysql&sql=…; other non-default options travel packed. For example ?dialect=postgresql&sql=select%20id%2Cname%20from%20users%20where%20active%3Dtrue%20order%20by%20name.
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser — network requests go only to the services named on this page.