← All tools
🗄️

SQL Formatter

Turn a one-line or messy query into clean, readable SQL — pick your database’s dialect, keyword case and layout, or compact it back to one line. Runs in your browser; queries are never uploaded.

Free · No sign-up

How to use SQL Formatter

  1. 1. Paste your query into the input box or try an example.
  2. 2. Pick your SQL dialect so its quoting, keywords and parameters are recognized.
  3. 3. Set keyword case, indent, layout and where AND / OR go — the result updates as you type.
  4. 4. Copy or download the formatted SQL, or press Compact to put each statement on one line.

Frequently asked questions

Is my SQL sent to a server?

No. The formatter library is loaded into this page and runs in your browser, so queries with table names or data never leave your device.

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, DuckDB, ClickHouse, Spark, Hive, Trino/Presto, Db2, Db2 for i, TiDB, SingleStoreDB and Couchbase N1QL.

Does formatting change what my query does?

No. Only whitespace and the letter case of keywords change. Strings, quoted identifiers, comments and numbers are kept exactly, so the query returns the same results.

Why does it say it couldn’t format my query?

The formatter has to parse the SQL. A typo, an unclosed parenthesis or syntax from another database stops it, and the message shows the line and column. Picking the right dialect often fixes it. It isn’t a full SQL validator, though.

What does Compact do?

Compact puts each statement on a single line by collapsing whitespace outside strings and identifiers and removing -- and /* */ comments (MySQL /*! */ hints are kept). It’s handy for logs, ORMs and config files.

Should SQL keywords be uppercase?

SQL isn’t case-sensitive for keywords, so it’s a style choice. Uppercase keywords (SELECT, FROM, WHERE) are the most common convention because they stand out from table and column names.

🛠️ Browse all text & developer guides and tools →