← All free tools Developer tools

SQL formatter/beautifier

Format & beautify your SQL code with ease.

About this tool

The SQL formatter turns a long, hard-to-read query into neatly indented SQL, with each clause on its own line. It can also do the opposite and compress a query onto a single line.

How to use the SQL formatter

  1. Paste your SQL: one query or several.
  2. Choose the style: Format and indent, or Compress to one line.
  3. Choose UPPERCASE keywords, or Keep as typed.
  4. Press Format and copy the result.

Before and after

select id,name from users where active=1 order by name

becomes

SELECT
  id,
  name
FROM
  users
WHERE
  active = 1
ORDER BY
  name

Good to know

Uppercasing changes only the SQL keywords, like SELECT and WHERE. Table and column names, strings and comments are left exactly as they were, so the query does the same thing. The formatter reads standard SQL, so it works for MySQL, MariaDB, PostgreSQL, SQLite and SQL Server queries.

Formatted SQL is easier to review, debug and share in code reviews and documentation; compressed SQL fits neatly in logs or a line of code.

Have a project in mind?

Have a brand or a product to grow?