SQL Formatter

Beautify MySQL & PostgreSQL

Format SQL online for MySQL, PostgreSQL, SQLite, BigQuery, and more. Live beautify with dialect and indent—does not run queries.

This conversion runs only in your browser — nothing is uploaded.

  • Input0
  • Output0
  • OptionsStandard SQL · 2 spaces

Input

Output

What is this tool?

This SQL formatter beautifies queries for Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, BigQuery, PL/SQL, and T-SQL. It restructures whitespace, line breaks, indentation (1–8 spaces), and uppercases keywords so pasted logs, ORM output, and PR snippets are easier to read.

It is not a database client: it does not execute SQL, check privileges, or prove that a query is valid for your schema. Dialect choice mainly affects how identifiers and vendor-specific tokens are tokenized for layout.

Use it to clean one-line queries from logs, prepare reviewable SQL in pull requests, and make joins or nested filters easier to scan before you run them elsewhere.

Common use cases

  • Expand a compact ORM or log query into clause-per-line form for code review
  • Reformat MySQL vs PostgreSQL snippets with the matching dialect so backticks or "quoted" identifiers stay correct
  • Normalize keyword case before sharing a query in docs or a ticket

How to use

  1. Select the dialect closest to your database, then indent 1–8 spaces.
  2. Paste SQL. Output updates live (debounced for large pastes).
  3. Fix any one-line parse error shown above the editors (usually unbalanced parentheses or truncated input).
  4. Copy the result. Sample loads a small SELECT + JOIN example.

Dialect notes

DialectTypical identifier quotingNotes
Standard SQL / PostgreSQL / SQLite"double"PostgreSQL also keeps :: casts readable.
MySQL / MariaDB`backtick`Prefer MySQL/MariaDB dialect for backtick identifiers.
BigQuery`project.dataset.table`Dataset-qualified names format cleanly in BigQuery mode.
PL/SQL / T-SQLVendor-specificProcedural blocks format best with the matching dialect.

Examples

Input / settingOutputNotes
select id, name from users where active = 1 order by created_at desc (Standard, 2)SELECT / FROM / WHERE / ORDER BY on separate linesClassic beautify + uppercase keywords.
select * from users where id::int = 1 (PostgreSQL)Cast kept as id::int with clauses splitDialect-aware cast token.
select * from \proj.dataset.table` where true` (BigQuery)Backtick-qualified table preservedVendor quoting edge many generic formatters mishandle.
SELECT * FROM users WHERE (Parse error at EOF / expected )Structural failure—not a schema or “wrong column” check.

Practical pitfalls

  • This is not query execution or DB validation. A formatted query can still be wrong for your schema, permissions, or engine version.
  • Wrong dialect can mistreat identifier quotes (" vs `) and vendor functions—pick the engine you will run against.
  • Minify / one-line compact is out of scope; only pretty-print is available.
  • Typos in keywords (selekt) may pass through without an error—the formatter is not a full SQL linter.

References

Last reviewed: 2026-07-27

Frequently asked questions

Does formatting change how my query runs?
It mainly changes whitespace, line breaks, and keyword casing. Semantics can still break if the wrong dialect is selected (quoting, vendor functions). Always review before running in a database.
Which SQL dialects are supported?
Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, BigQuery, PL/SQL, and T-SQL. Pick the closest match so identifier quoting and vendor tokens format correctly.
Can I minify SQL to one line?
No. This page only beautifies (pretty-print). Compacting to a single line is out of scope—use your editor or a dedicated minifier if you need that.
Is my query uploaded?
No. Formatting runs only in your browser.