Skip to main content
ToolsBay

SQL Formatter

Indent and align SQL queries across every major dialect.

Runs entirely in your browser — nothing is uploaded

Your query

1 line

Formatted query

1 line

Frequently asked questions

Why does the dialect matter?

Each database adds its own syntax — PostgreSQL has ::casts and $$ blocks, SQL Server uses [bracketed] identifiers, BigQuery uses backticks and array types. Picking the right dialect avoids the formatter mangling syntax it does not recognise.

Does it run or validate my query?

No. It parses the query well enough to lay it out, then prints it. It never connects to a database and does not check that your tables or columns exist.

Is it safe to paste a production query?

Formatting happens entirely in your browser and nothing is transmitted. Note that a query often contains table names and sometimes literal values, which is exactly why a browser-based tool is the right choice here.

Why are keywords uppercased?

It is the long-standing SQL convention and makes the shape of a query scannable — SELECT, FROM, WHERE and JOIN stand out from your table and column names.

Why SQL formatting matters more than it looks

SQL is written as one long expression, and a query of any complexity becomes unreadable the moment it exceeds a couple of lines. A well-formatted query puts each clause on its own line, indents joins under the tables they attach to, and lines up conditions so the logic is visible at a glance.

That readability is not cosmetic. The most common SQL bugs — a join condition in the WHERE clause instead of ON, a missing parenthesis around an OR, a GROUP BY that omits a selected column — are obvious in formatted output and nearly invisible in a single-line query.

Dialects

Standard SQL is a specification that no database implements exactly. PostgreSQL, MySQL, SQLite, SQL Server, BigQuery and Snowflake each extend it in ways that a generic parser does not recognise. Selecting your dialect means the formatter understands the syntax rather than treating it as an unparseable token.

When your query returns JSON, the JSON formatter will make the result readable, and JSON to CSV will turn it into a spreadsheet.

All developer tools