SQL Formatter 🔒 Your data never leaves your browser.

Beautify messy SQL — supports MySQL, PostgreSQL, SQLite, T-SQL and more.

Ctrl+SDownload

About this tool

A 400-character one-line query from a log file becomes readable in one paste: keywords aligned, subqueries indented, clauses on their own lines. Pick your dialect — MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), BigQuery and more — so dialect-specific syntax formats correctly.

Formatting runs locally with the sql-formatter library, loaded only on this page. Queries containing table names or data never leave your machine.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), BigQuery, and MariaDB. Dialect matters for things like quoting identifiers with backticks vs. brackets and dialect-specific keywords, so pick the one matching your database for the most accurate formatting.

Does it validate that my SQL is correct, or just reformat it?

It parses the query in order to format it, so syntax errors are caught and reported with a line and column pointer — but it doesn't check semantics, like whether a table or column you referenced actually exists.

Can I format multiple statements at once?

Yes. Separate statements with semicolons and the tool formats and counts all of them in one pass; the trailing statement doesn't need a closing semicolon.

Why would I choose uppercase vs. lowercase keywords?

It's a style preference. Uppercase (SELECT, FROM, WHERE) is a long-standing SQL convention that visually separates keywords from identifiers, while lowercase reads more like modern application code. "Preserve" keeps whatever casing you originally typed.

Is my SQL query uploaded anywhere?

No. Formatting runs entirely in your browser through a JavaScript library — queries, including any embedded literal values, never leave your device.