Skip to content
Developer

SQL Formatter

Paste a query and get it laid out readably, with the keyword case and indentation you want. Choose the dialect so identifiers are not mistaken for keywords.

Press Esc to clear

Formatted

About the SQL Formatter

A query that has been through a few rounds of editing tends to arrive as one long line, or with indentation that reflects the order it was written in rather than its structure. Formatting it is the fastest way to see what it actually does — which tables are joined, which conditions belong to which clause, and where the subquery ends.

Choosing the dialect matters more than it looks. SQL is a family of languages rather than one, and the differences are exactly where a formatter can do damage: reserved words vary, quoting of identifiers varies, and constructs like BigQuery's arrays or SQL Server's bracketed names are not valid elsewhere. Formatting with the wrong dialect can mangle an identifier that happens to collide with a keyword in the dialect the formatter assumed.

Uppercase keywords are the convention for a reason that outlives style preference: SQL has no other visual distinction between the language and your schema, so capitalising SELECT, FROM and WHERE makes the shape of a query legible at a glance. The option to preserve or lowercase is there for codebases that have decided otherwise.

Minifying does the opposite and is genuinely useful: it strips comments and collapses whitespace, which is what you want before embedding a query in a string literal, a configuration value or a log line.

The formatter is loaded only when you open this tool, and your query never leaves the browser — which matters, since a real query usually reveals your schema and sometimes your data.

Frequently asked questions

Why do I need to pick a dialect?

Because reserved words and identifier quoting differ between them. Formatting with the wrong dialect can mangle a column name that happens to be a keyword in the one assumed.

Should SQL keywords be uppercase?

It is the long-standing convention, and it earns its keep: SQL has no other visual separation between the language and your schema, so capitals make the structure of a query readable at a glance.

Is my query sent anywhere?

No. It is formatted in your browser. That matters because a query usually exposes your schema and sometimes your data.