SQL Formatter
Format and beautify SQL queries with dialect support
About SQL Formatter
Turns a one-line or messy query into readable SQL, putting SELECT, FROM, JOIN, WHERE and other clauses on their own lines with indented column lists, ready to copy. It is built on the open-source sql-formatter library and runs entirely in your browser, so queries copied from production logs never leave your machine. Handy for untangling ORM-generated SQL before a code review.
Category: Text.
Frequently asked questions
What SQL dialects are supported?
▾
Six: standard SQL, MySQL, PostgreSQL, SQLite, T-SQL (SQL Server) and MariaDB. Pick the one that matches your database so dialect-specific syntax, such as PostgreSQL :: casts or T-SQL @variables, is parsed correctly; quotes and identifiers are never rewritten.
Does formatting change query behavior?
▾
No. Formatting only affects whitespace, indentation, and keyword capitalization. The resulting query is semantically identical to the input.
Can I use lowercase keywords or a different indentation?
▾
No. Keywords such as SELECT, FROM and LEFT JOIN are always uppercased and nested lines use 2-space indentation. Table and column names, function names and data types keep the case you typed.
Why do I get a parse error?
▾
The query is tokenized and parsed for the selected dialect, so syntax from another dialect, like a PostgreSQL :: cast under standard SQL, or unbalanced parentheses stops formatting with an error that gives the line and column. It does not check whether tables or columns actually exist.