Skip to content
FileTinker

SQL Formatter

Paste a messy SQL query and get it cleanly indented and capitalised, with support for MySQL, PostgreSQL, SQLite, T-SQL and more. Everything runs in your browser, so your queries are never uploaded.

The result will appear here.

How to format SQL

  1. Choose the SQL dialect that matches your database.
  2. Paste your query into the input box.
  3. Copy the cleanly formatted SQL from the output box.

About formatting SQL

A SQL formatter re-indents a query and standardises keyword casing and line breaks so its structure — clauses, joins, sub-queries — is easy to scan. Consistent formatting makes long queries reviewable, reduces mistakes, and keeps diffs clean when queries live in version control.

Different databases extend SQL with their own keywords and syntax, so picking the right dialect produces the most accurate result. This formatter runs entirely in your browser, so even queries containing table names or business logic never leave your device.

Most unreadable SQL was never typed by a person. ORMs and query builders emit statements as a single long line; logging and monitoring tools strip line breaks when they capture queries; and BI tools generate SQL with machine-made aliases. When one of those queries misbehaves, formatting it is the natural first step — once each clause sits on its own line, you can actually see which join exploded the row count or where a filter went missing.

The conventions a formatter applies have a logic behind them. Uppercase keywords date from the era before syntax highlighting, when capitals were the only way to make SELECT and WHERE stand out from table and column names — and the habit stuck because it still helps in plain-text contexts like logs, diffs and documentation. One clause per line, with indentation showing nesting, mirrors how you reason about a query: what am I selecting, from where, filtered how.

Frequently asked questions

How do I format SQL?

Pick your dialect, paste the query, and the formatted version appears instantly with consistent indentation and keyword casing. Copy it with one click.

Which dialects are supported?

Standard SQL plus MySQL, PostgreSQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle (PL/SQL) and BigQuery — choose the one that matches your database for the most accurate formatting.

Does it change what my query does?

No. Formatting only adjusts whitespace and casing for readability; the query itself is unchanged.

Is my SQL uploaded?

No. The query is formatted entirely in your browser; nothing is sent to a server.

Will formatting fix a broken query?

No. A formatter rearranges whitespace and casing; it does not validate syntax or repair mistakes, so a query with a missing comma or an unclosed parenthesis stays broken — just more readably so. That said, formatting is a genuinely useful debugging step: once the structure is laid out clause by clause, errors like an extra bracket or a join without a condition are far easier to spot by eye.