Add to Chrome Add to Edge

SQL Beautifier

Format or minify SQL for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more.


SQL Beautifier

SQL Beautifier turns a long, one-line query into readable SQL: each clause on its own line, columns and conditions indented, and keywords in a consistent case. Choose your database's dialect so its own syntax is understood, pick upper or lower case keywords and the indent you use, and copy the result. The Minify button does the opposite and packs a query onto one line. Your SQL is formatted in your browser and never sent anywhere.

How to format SQL

  1. Paste your query into the editor (a sample query is there to try first).
  2. Choose the SQL dialect, for example MySQL, PostgreSQL or SQL Server (T-SQL).
  3. Choose Keywords (UPPER CASE, lower case or as written) and the Indent (2 or 4 spaces, or a tab).
  4. Click Beautify SQL, then Copy.

Supported dialects

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, IBM Db2, Spark SQL, Trino / Presto, DuckDB and ClickHouse. Picking the right one matters for syntax that only some databases have, such as backtick-quoted names in MySQL, :: casts in PostgreSQL, square-bracket names in SQL Server or $$ blocks in PL/pgSQL. If formatting fails, the tool tells you where it stopped, which usually means a typo or the wrong dialect.

Formatting and minifying

  • Beautify for code reviews, documentation, debugging and pull requests: one clause per line makes joins, filters and grouping easy to follow.
  • Minify to put a query on one line for a config file, a log search or a string in code. It removes comments and extra spaces but keeps text inside quotes exactly as it is, so 'a -- b' stays intact.

Both only change whitespace, line breaks, comments (Minify) and keyword case. Table names, values and the logic of the query are not touched.

When it comes in handy

  • Reading queries copied from application logs, ORMs and query analyzers, which print SQL on one line.
  • Making SQL consistent before committing it or pasting it into documentation.
  • Understanding a complex query with many joins and subqueries.

For other code, use the JSON Beautifier, the HTML Formatter or the CSS Formatter.

Frequently asked questions

Does formatting change what the query does?
No. Only whitespace, line breaks and keyword case change, and SQL ignores all three. Text inside quotes is never changed.
Is my SQL sent to your server?
No. Formatting runs in your browser, so queries with real table names or data stay on your device.
Can it format several statements at once?
Yes. Separate them with semicolons; each statement is formatted, with a blank line between them.
Does it check my SQL for errors?
Only partly. It reports SQL it cannot parse, but it does not connect to a database, so a query that formats well can still fail because of a wrong table or column name.

Related guides

Choose which cookies SEOpeck may use. You can change this at any time from "Cookie settings" at the bottom of every page.

Your tools

    Saved in this browser only. Nothing is sent to us.

    Popular tools