SQL Formatter

285 → 309 chars

Whitespace formatting only — this doesn't validate your query or check it against a real database schema, just re-indents and cases it consistently.

About SQL Formatter

Paste a SQL query — a one-line export from a log, a minified query from an ORM, a report someone pasted into Slack — and get it back with consistent indentation, line breaks and keyword casing. Runs entirely in your browser, so a query touching real table or column names never has to leave your machine.

A SQL query that reads fine as a single dense line becomes hard to audit the moment it has more than one join or a nested subquery — where does this WHERE clause actually end, and which JOIN is it attached to? Formatting breaks each clause onto its own line and indents nested structure consistently, which is usually enough on its own to spot a misplaced condition or a join on the wrong key.

SQL dialects genuinely differ in more than keywords — MySQL's backtick identifiers, PostgreSQL's `::type` casts, SQL Server's bracketed `[identifier]` names and BigQuery's own function set all need to be recognized correctly rather than mistaken for something else while reformatting. Picking the right dialect here matters for exactly that reason, not just cosmetics.

This is a whitespace formatter, not a query validator or a linter — it doesn't check your SQL against a real schema, catch a typo'd column name, or warn about a missing index. It reformats the structure it's given as faithfully as it can, the same honest scope every formatter on this site keeps.

What you can use it for

  • Make a one-line or minified SQL query readable again before reviewing or debugging it.
  • Standardize indentation and keyword casing across a team without a build-time formatter.
  • Check where a WHERE clause or JOIN condition actually applies in a query with nested subqueries.
  • Clean up a query copied from a log, an ORM's debug output, or a colleague's message.
  • Convert keyword casing to match a team's SQL style guide (uppercase, lowercase, or leave as typed).

How it works, step by step

  1. 1

    Paste a SQL query

    Any single or multi-statement query.

  2. 2

    Choose a dialect

    MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, Snowflake, and 14 more.

  3. 3

    Pick indent size and keyword case

    2 or 4 spaces, a tab, and uppercase/lowercase/preserve.

  4. 4

    Copy the result

    Formatting only — nothing about the query's meaning changes.

Frequently asked questions

Which SQL dialects are supported?

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

Does this validate my SQL or check it against a database?

No — it's a whitespace formatter, not a linter or a validator. It reformats indentation, line breaks and keyword casing without connecting to any database or checking column/table names against a real schema.

Will formatting change what my query does?

No — only whitespace and, if you choose, keyword casing change. Identifiers, string literals, operators and the query's actual logic are left exactly as written.

Is my SQL uploaded anywhere?

No. Formatting happens entirely in your browser — nothing is sent to a server.