Free Tool · No signup required

SQL Formatter & Beautifier — Clean, Readable SQL in One Click

Format MySQL, PostgreSQL, SQLite, and MSSQL with keyword casing and indentation

1
2
3

Minified SQL from an ORM, a database export, or an auto-generated query is nearly impossible to debug at a glance. This SQL formatter adds consistent indentation, breaks clauses onto their own lines, and applies uniform keyword casing so you can immediately understand the structure of any query. Choose your dialect (MySQL, PostgreSQL, SQLite, or MSSQL), select 2-space, 4-space, or tab indentation, toggle keywords between UPPERCASE and lowercase, and click Format SQL. The result is clean, structured SQL ready to paste into your editor, pull request, or documentation.

How to Format SQL Online in 3 Steps

Paste messy SQL, pick your options, and get clean formatted output in seconds.

1
Step 1

Paste your SQL

Enter your raw, minified, or inconsistently formatted SQL into the left panel. You can paste a single SELECT query, a multi-table JOIN, a subquery, or a full DDL statement. Click Sample to load an example query with JOINs, WHERE conditions, GROUP BY, and ORDER BY to see the formatter in action.

2
Step 2

Choose your formatting options

Select your SQL dialect from the dropdown (MySQL, PostgreSQL, SQLite, or MSSQL). Pick your preferred indentation: 2 spaces for compact output, 4 spaces for maximum readability, or a tab character to match your editor settings. Toggle keywords to UPPERCASE (standard SQL convention) or lowercase (preferred by some teams).

3
Step 3

Format and copy

Click the Format SQL button. The right panel shows the formatted, indented SQL with each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT) on its own line. Click Copy to paste the result into your SQL editor, query runner, or documentation without further editing.

Features

MySQL, PostgreSQL, SQLite, and MSSQL dialect selection

UPPER and lower keyword case toggle

2-space, 4-space, or tab indentation options

Newlines before all major SQL clauses

Preserves string literals and quoted identifiers unchanged

Sample query for instant demo

Copy formatted SQL to clipboard in one click

Runs entirely in your browser — SQL never sent to a server

Related Tools

Frequently Asked Questions

Does the formatter change the meaning of my query?

No. The formatter only changes whitespace and keyword case — it never modifies column names, table names, string literals, or query logic. The formatted SQL is semantically identical to the original and will produce the same result when executed.

Can I format stored procedures and functions?

The formatter handles standard DML (SELECT, INSERT, UPDATE, DELETE) and DDL (CREATE TABLE, ALTER TABLE, DROP) well. Complex procedural blocks (BEGIN...END, DECLARE, IF...THEN) inside stored procedures may have limited formatting support since procedural SQL syntax varies significantly between dialects.

Why should I format SQL in code reviews?

Consistently formatted SQL is easier to diff, review, and understand at a glance. Code reviewers can quickly identify which tables are joined, what conditions are applied, and whether index columns appear in WHERE and JOIN clauses. Many teams enforce a SQL formatting style in their linting rules.

What SQL style guide should I follow?

There is no single universal standard, but popular conventions include putting each major clause on its own line, using UPPERCASE for SQL keywords, using lowercase for table and column names, and aligning ON conditions with their JOIN keyword. The formatter's output follows these common conventions.

How do I format SQL in VS Code?

Install the SQLTools extension or a dedicated SQL formatting extension such as sql-formatter. You can also paste SQL into this online formatter, copy the result, and paste it back. For team-wide consistency, configure the formatter in your .editorconfig or add a SQL linting step to your CI pipeline.