SQL Beautifier

Format, indent or minify SQL queries for any database

Pretty-print SQL with consistent indentation and keyword case, or minify it onto one line. Supports MySQL, PostgreSQL, SQLite, MariaDB, SQL Server, Oracle PL/SQL, BigQuery and Snowflake.
Try an example:

Output will appear here...

About SQL Beautifier

How it works

  1. Format mode parses your SQL with sql-formatter using the rules of the dialect you pick, then lays out each clause (SELECT, FROM, WHERE, JOIN...) on its own line with consistent indentation.
  2. Keywords can be upper-cased, lower-cased or left as typed; names and string values are never changed.
  3. Minify mode removes comments and extra whitespace, but leaves quoted strings untouched, giving a compact one-line query.

What you need

  • One or more SQL statements, separated by semicolons. Any dialect works - choose yours for the best results.

Tips

  • If parsing fails, choose your database's dialect: special syntax like PostgreSQL ::casts or T-SQL [brackets] needs it.
  • Minify long queries before putting them into code, logs or config files.
  • Formatting does not change what the query does - it only changes whitespace and keyword case.

Limitations

  • The formatter does not run or validate your query against a database, so logical errors are not detected.
  • Very unusual vendor syntax may not be recognised.

Runs in your browser. Your SQL stays in your browser.

Frequently asked questions

Does formatting change my query?+

No. Only whitespace, line breaks and (if chosen) the case of SQL keywords change. Table names, column names and string values stay exactly as written.

Why does it say it could not parse my SQL?+

The formatter uses grammar rules per database. Pick your dialect (for example PostgreSQL or SQL Server), and check for unbalanced quotes or brackets.

Should SQL keywords be uppercase?+

It is a style choice. Uppercase keywords (SELECT, FROM) make queries easy to scan and are the most common convention; databases do not care.

Is it safe to paste production queries?+

Yes - formatting runs in your browser and nothing is sent anywhere. Still avoid sharing queries that contain real customer data.