SQL formatter

Format or minify queries

No database: AIMRAN doesn't store your files, text or results

What is SQL formatter?

A long SQL query written on a single line is very hard to read. This formatter lays it out with line breaks and indentation so it makes sense at a glance, and puts keywords such as SELECT or WHERE in uppercase.

It also does the opposite: it minifies the query onto a single line, removing spaces and comments, to embed it in code.

How to use it

  1. Paste your SQL query or open a .sql file.
  2. Choose the action: “Format” or “Minify”.
  3. Select your database's dialect.
  4. Adjust the keyword case, indentation and tabular style.
  5. Copy or download the result.

Advantages

Technical details

Formatting uses the sql-formatter library with the dialects standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, Spark SQL, Trino/Presto and IBM Db2. You can choose the case of keywords, data types and functions (uppercase, lowercase or unchanged), indentation of 2 or 4 spaces or tabs, and the tabular style, which aligns keywords in a left-hand column. Minification removes -- and /* */ comments (unless you choose to keep them) and extra spaces around punctuation, respecting string literals and quoted identifiers. Files up to 10 MB can be opened. It doesn't run the queries.

Frequently asked questions

How do I format a SQL query?

Paste the query, leave the action on “Format”, choose your database's dialect and copy the tidy result.

Do SQL keywords have to be uppercase?

No. SQL keywords are case-insensitive, but writing them in uppercase is a convention that improves readability.

Which SQL dialects are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL, Trino/Presto and IBM Db2.

What is minifying SQL for?

To turn the query into one compact line, without comments or extra spaces, useful when embedding it in code or configuration files.

Does it check whether my query is correct?

It only formats. If the syntax can't be parsed it warns you, but it doesn't run the query or check tables or columns.

More Developers tools