SQL Formatter

Format, beautify, or minify SQL queries instantly. Auto-indent, uppercase keywords, line-break clauses. Works for MySQL, PostgreSQL, SQLite, SQL Server. Free, no signup.

Free·No account required·Files deleted immediately·Built by Smit Parekh

How It Works

Using SQL Formatter in 3 Steps

1

Paste Your Query

Drop any SQL — single-line, minified, or messy auto-generated output. Comments and string literals are preserved.

2

Pick Your Style

Choose 2 / 4-space indent or tabs, and toggle UPPERCASE keywords on or off to match your team's convention.

3

Copy or Minify

Copy the formatted result, or use the Minify button to strip whitespace down to a single line — useful for embedding in code.

Use Cases

Who Uses SQL Formatter?

Backend Developers

Clean up auto-generated ORM queries before committing them to Git or pasting into PR descriptions.

Data Analysts & DBAs

Make complex CTEs and joins readable when reviewing a teammate's query in Slack or a spreadsheet.

Documentation Writers

Embed beautifully formatted SQL examples in your docs without a separate VS Code session.

FAQ

SQL Formatter — Frequently Asked Questions

Everything you need to know before you start.

Which SQL dialects does the formatter support?

It works for ANSI-style SQL used by PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, BigQuery, Snowflake, and Redshift. Vendor-specific keywords are kept as-is and won't be reformatted incorrectly.

Does it preserve my comments?

Yes. Both line comments (-- ...) and block comments (/* ... */) are preserved on their own lines in the output.

Will it break complex CTEs and subqueries?

No. Parentheses are tracked and indentation increases for each nested level, so CTEs (WITH ... AS (...)) and subqueries stay readable.

Is my SQL sent to a server?

Never. Formatting happens entirely in your browser using JavaScript — safe for confidential queries containing internal table names or business logic.