My Toolbox

SQL Formatter and Beautifier

Make SQL queries readable or minify them to one line, for Standard SQL, MySQL, PostgreSQL and Transact-SQL.

About the SQL Formatter

Beautifies or minifies SQL queries and highlights syntax errors. It supports Standard SQL, MySQL, PostgreSQL and Transact-SQL (T-SQL), and can set keyword case (for example UPPERCASE).

How to use it

  1. Paste your SQL query.
  2. Choose the dialect: Standard SQL, MySQL, PostgreSQL or Transact-SQL.
  3. Pick UPPERCASE or lowercase keywords and an indent of 2 or 4 spaces.
  4. Click Format to beautify, or Minify to put the query on one line, then copy the result.

Good for

Tip: Pick the dialect that matches your database; functions and quoting rules differ between MySQL, PostgreSQL and SQL Server.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL and Transact-SQL (SQL Server).

Does minifying change my string values?

No. Text inside quotes is kept exactly as written, and -- comments are turned into /* */ comments so they cannot hide the rest of the query.

Does it run the query?

No. It only formats the text; nothing is sent to a database.

More free tools