Skip to content

SQL Formatter & Beautifier

Format messy SQL into clean, readable queries — MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more. Minify SQL too.

About SQL Formatter & Beautifier

This SQL formatter turns long one-line queries into clean, readable SQL with each clause on its own line and consistent indentation. Pick your dialect — MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake and more — and choose UPPER, lower or original keyword case.

Use Minify to squeeze a query onto a single line for code or config files; strings and optimizer hints are kept intact. Copy the result or download it as a .sql file. The SQL beautifier only rearranges text: it never connects to a database, and your queries never leave your browser.

How to use SQL Formatter & Beautifier

  1. Paste one or more SQL queries.
  2. Choose your database dialect and how keywords should be written (UPPER, lower or as typed).
  3. The formatted query appears instantly; use Minify for a single-line version.
  4. Copy it or download it as a .sql file.

Frequently asked questions

Does this run or check my query against a database?

No. It only rearranges the text. Nothing is sent anywhere and no database is touched, so it is safe for production queries.

Why choose a dialect?

Databases differ in syntax — backtick identifiers in MySQL, square brackets in SQL Server, $ strings in PostgreSQL. Picking the right dialect lets the formatter read these correctly.

Are my comments kept?

Formatting keeps comments. Minify removes ordinary comments but keeps optimizer hints (/*+ … */) and MySQL conditional comments (/*! … */).

How do I format a SQL query online?

Paste the query, choose your database dialect and keyword case, and the formatted SQL appears on the right. Copy it or download a .sql file.

Can it format several queries at once?

Yes. Separate the queries with semicolons and each one is formatted, with a blank line between them.

Should SQL keywords be upper case?

SQL is not case-sensitive for keywords, but writing them in upper case (SELECT, FROM, WHERE) is a common convention that makes queries easier to read.

People also search for

sql formatter · sql beautifier · format sql online · sql formatter online · mysql formatter · sql query formatter · postgresql formatter · sql server formatter · sql minifier · sql pretty print

Related tools