SQL Formatter

SQL Tools

Format one-line SQL into readable, indented statements.

Runs entirely in your browser โ€” nothing is uploaded

A query written as one long line is not wrong, it is just unreadable โ€” and unreadable queries are where bugs hide. This formatter reflows SQL onto indented lines with the keywords aligned, so joins, filters and grouping can be seen rather than parsed by eye. It understands five dialects, and it never changes what the query does.

What people do next

Features

  • Five dialects: PostgreSQL, MySQL, SQLite, SQL Server and BigQuery.
  • Keywords, joins and clauses aligned on their own lines.
  • Comments and string literals preserved exactly as written.
  • Handles multi-statement scripts in one pass.
  • Formatted in your browser โ€” queries containing real table and column names are never uploaded.

How to use the SQL Formatter

  1. 1Paste your SQL.
  2. 2Pick the dialect you are writing for.
  3. 3Copy the formatted query back out.

Frequently asked questions

Will it change what my query does?

No. Formatting only adds and removes whitespace and line breaks; the tokens themselves are untouched, so the query is byte-for-byte equivalent to the parser. Comments and the contents of string literals are preserved exactly, including any indentation inside them.

Why does the dialect matter for formatting?

Because dialects disagree about what is a keyword and what is an identifier. BigQuery has backtick-quoted names and array syntax, SQL Server uses square brackets, MySQL allows backticks โ€” formatting with the wrong dialect can indent a quoted identifier as though it were a keyword. Picking the right one gives cleaner output, and it never breaks the query either way.

Can it format a whole migration file?

Yes. Statements separated by semicolons are formatted independently and kept in order, so a migration or a seed script comes back with each statement laid out on its own.

Should formatted SQL be committed to the repository?

Generally yes. A consistently formatted query produces a clean diff when it changes, which is the whole argument โ€” a one-line query that gets edited shows up as a single modified line with no indication of what actually moved.

Is my SQL sent anywhere?

No. Formatting runs entirely in your browser, which matters here because queries routinely contain real schema names, and sometimes real values in the WHERE clause.