Developer

SQL Formatter & Beautifier

Format and beautify SQL live for 20 dialects, including MySQL, PostgreSQL, SQL Server, Oracle, BigQuery and Snowflake, with syntax-highlighted output, keyword case and indent options. Free, runs in your browser.

🔒 100% private. SQL is processed locally in your browser.
Keywords
More options

Several statements separated by ; are formatted one after another. Drop a .sql file on this box.

Formatted SQL

            

What is this tool?

This SQL formatter turns long, one-line queries into readable, indented SQL. It uses the open-source sql-formatter library, which reads your query token by token, so strings, comments, subqueries, CASE expressions and two-word keywords like LEFT JOIN are handled correctly and nothing inside a quoted string is changed. Pick one of 20 dialects (Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, DuckDB, Spark, Trino and more), keyword case, and an indent of 2 spaces, 4 spaces or a real tab. More options set function and data type case, tabular layout, where AND and OR go, blank lines between queries and dense operators. Several statements separated by semicolons are formatted one after another, and the output is syntax-highlighted. Minify puts a query on one line. You can open or drop a .sql file and download the result. Your SQL is never uploaded.

How to Use

  1. Paste your query into the SQL input pane, or open or drop a .sql file. It formats as you type.
  2. Choose your Dialect, keyword case and indent. Open More options for function case, layout and spacing.
  3. Press Format SQL or Ctrl+Enter to format now, or Minify for a single-line version.
  4. If a query cannot be read, the output names the line and column and the input jumps there; check the dialect.
  5. Press Copy or Download .sql in the output pane.

Frequently Asked Questions

Does the formatter check my SQL for errors?

Partly. It reads the query token by token for the chosen dialect and reports where it finds something it cannot read, such as an unclosed string or a symbol the dialect does not use. It does not check table names or run the query, so a formatted query can still fail in your database.

Can formatting change what my query does?

No. Formatting changes only whitespace, line breaks and the case you choose for keywords, functions and data types. String literals, quoted identifiers and comments are left exactly as written. Minify also keeps strings intact but removes -- comments.

What does the Dialect option change?

It tells the formatter which syntax to expect: for example backtick identifiers and # comments in MySQL, $$ strings and :: casts in PostgreSQL, or [brackets] and TOP in SQL Server. Pick the database you use; Standard SQL is a safe default for simple queries.

Other tools

There are more calculators, converters and editors on Wivrix. If something is missing, tell us.