MADE TO BE USEFUL. A growing collection of free tools for everyday work.
DEVELOPER TOOL / SQL

Free Online SQL Formatter & Beautifier

Turn messy SQL into clean, readable queries. Put each clause on its own line, indent JOINs and subqueries, and choose how keywords are cased — then copy it or minify it again.

Works with common SQL: SELECT, INSERT, UPDATE, DELETE, CTEs, JOINs, UNION and subqueries. Your queries stay in your browser.

✓ Free to use · No signup required · Processed in your browser
SQL Formatter workspace
PASTE SQL · FORMAT OR MINIFY · COPY
● READY TO USE
Paste a SQL query and click Format SQL.
SQL WORKSPACEMOSANKIT / DEVELOPER TOOLS
THE BASICS

What Is a SQL Formatter?

A SQL formatter rearranges a query with consistent line breaks, indentation and keyword casing, without changing what it does. Long one-line queries from logs, ORMs or generated code become easy to read and review.

Readable SQL is easier to debug, easier to review in a pull request and easier for the next person to understand.

BUILT FOR THE JOB

Key Features of MoSanKit SQL Formatter

≡

Clause-per-Line Layout

SELECT, FROM, WHERE, GROUP BY, ORDER BY and more start on their own lines.

↳

JOINs and Subqueries

JOIN conditions and nested subqueries are indented so the structure is obvious.

Aa

Keyword Casing

Uppercase, lowercase or keep keywords exactly as written.

⌁

Minify Too

Collapse a query to a compact single line for logs or code strings.

✓

Query-Safe

Strings, quoted identifiers and comments are preserved, and the tool checks that formatting did not change the query.

◎

Private by Design

Queries are formatted locally and never uploaded.

QUICK AND SIMPLE

How to Format SQL

01 / PASTE

Paste your query

Paste one or more SQL statements.

02 / OPTIONS

Choose casing and indent

Pick keyword case and 2, 4 or tab indentation.

03 / FORMAT

Click Format SQL

Your query appears neatly structured.

04 / COPY

Copy or download

Copy the result or save it as a .sql file.

MADE FOR EVERYDAY WORK

Who Can Use This Tool?

Backend DevelopersClean up queries from logs and ORMs.
Data AnalystsMake long reporting queries readable.
Database AdminsReview and document queries.
QA EngineersRead generated test queries.
StudentsLearn SQL structure from well-formatted examples.
Code ReviewersReview SQL changes more easily.
GOOD TO KNOW

A few things, answered.

Quick answers about using the MoSanKit SQL Formatter.

It formats common, standard-style SQL used by MySQL, PostgreSQL, SQL Server, SQLite and others. Very dialect-specific syntax may be laid out simply rather than perfectly.

No. The tool only changes whitespace and keyword case. It also checks the result against your original and warns you if anything looks unusual.

Yes. Line and block comments are preserved when formatting.

Yes. Separate statements with semicolons and each is formatted in turn.

No. Formatting happens entirely in your browser.

It removes comments and extra whitespace to produce a compact single-line version of the query.

Readable queries,
fewer mistakes.

Explore more free developer tools from MoSanKit.

Explore All Tools ↗