Developer Tools

SQL Formatter

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

Turn a dense one-line query into readable, indented SQL for the database you use, entirely in your browser. Need to compare two versions of a query? Use Text Diff.

Your SQL never leaves your device. It is formatted entirely in your browser; it is never run against a database.
0 characters
Keywords
Put AND / OR at the
This tool only changes spacing, line breaks and (if you choose) keyword case; it doesn't validate your query against a database or check that table and column names exist. If the result differs in any other way, you'll see a warning. Formatting is not a security measure: never build queries by pasting untrusted values into SQL.

How it works

Private SQL formatting in your browser

1

Paste your SQL

Paste one or more statements, or load a .sql file. Nothing is run or uploaded.

2

Pick a dialect and style

Choose your database, keyword case, indentation and where AND / OR go.

3

Copy or download

Copy the formatted SQL or download it as a .sql file.

Use cases

When this comes in handy

Read a query from a log

Expand a query copied from an application log or an ORM into something you can follow.

Keep code review diffs clean

Apply one consistent style so reviews focus on what the query does, not how it is spaced.

Prepare SQL for documentation

Format examples with consistent keyword case and indentation before pasting them into docs.

FAQ

Common questions

Is my SQL sent anywhere?

No. Formatting happens in your browser and the query is never run against any database.

Does formatting change what my query does?

It should only change spacing, line breaks and, if you choose, the case of keywords. The tool checks this and shows a warning if the output differs in any other way. String literals and comments are kept exactly as written.

Which databases are supported?

Standard SQL plus PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Redshift, Spark, Hive, Trino, Db2, DuckDB and ClickHouse. Choosing the right dialect matters for vendor-specific syntax.

Why do I get a parse error on a valid query?

The formatter has to understand the syntax. Vendor-specific features usually need the matching dialect selected. The message shows the line and column where it stopped.

Does it validate or minify SQL?

It does not validate against a schema or database, and it does not minify: collapsing whitespace can change the meaning of queries that contain comments or strings.

Related Tools