Skip to content

SQL Formatter

5 dialects, auto-detect, 3 keyword-case modes, browser-only.

Share

Settings

191 chars, 1 lines, 10 keywords, 23 identifiers
postgresql
SELECT u . id, u . name, COUNT(o . id)
AS order_count
FROM users u
LEFT JOIN orders o
ON o . user_id = u . id
WHERE u . created_at > '2026-01-01'
GROUP BY u . id, u . name
ORDER BY order_count DESC
LIMIT 10;
207 chars, 9 lines
Tokenizer runs in your browser. SQL -table names, column names, literal data -never sent.
5
Dialects
3 modes
Keyword casing
Unlimited
Free uses per day
Browser
Runs in

What is the SQL Formatter?

A SQL formatter takes a messy one-line query and beautifies it into readable, indented SQL -keywords uppercased, clauses on separate lines, comments preserved. This one supports five dialects (PostgreSQL, MySQL, SQL Server, Oracle, SQLite) with auto-detection from syntax cues like RETURNING, TOP n, ROWNUM, or LIMIT a, b.

Most online formatters are single-dialect and ship 10MB of JS bundled with ads. We tokenize SQL in pure JS, run the formatter in your browser, and never see your queries. Use it for code reviews, debugging ORM-generated SQL, or making auto-generated query strings readable before pasting into a ticket.

How it works

Step 1
Paste your SQL
Single query, minified one-liner, multi-statement script -paste anything.
Step 2
Pick dialect + style
Auto-detect or choose dialect. Set keyword case (upper / lower / preserve) and indent.
Step 3
Copy or download
Formatted SQL ready to paste back into your editor, ticket, or migration file.

Features

5 dialects
PostgreSQL, MySQL/MariaDB, SQL Server (T-SQL), Oracle (PL/SQL), SQLite.
Auto-detect dialect
Reads RETURNING / TOP n / ROWNUM / LIMIT a,b cues to pick the right dialect.
3 keyword case modes
Upper (SELECT, FROM), lower (select, from), or preserve original casing.
Indent spaces config
2 or 4 spaces. Match your team's style guide. Default 2.
Comment-aware
-- single-line and /* block */ comments preserved exactly where you wrote them.
Multi-quote handling
Backticks (MySQL), [brackets] (SQL Server), "quotes" (PostgreSQL) pass through cleanly.
One-liner unfolder
500-char ORM-generated query gets broken onto readable multi-line output.
Browser only
Pure JS tokenizer. Your SQL -including table names + literal data -never leaves the page.

Why this formatter

5 dialects, auto-detected

Most free formatters lock dialect-specific syntax behind paid tiers. We ship all 5 free.

Browser-only privacy

Your SQL often contains real table names + sensitive data. We never see them. SqlFormat.org sends every query to their server.

Zero ads

No popups, no banner ads, no "sign up for Pro" interrupts. Just paste, format, copy.

Auto-detect saves clicks

No "pick dialect first" interrupt. Paste, get the right output, move on.

Who uses it

Backend devs
Cleaning up ORM-generated SQL before pasting into a ticket or code review.
Data engineers
Formatting analytical queries, dbt models, BigQuery SQL.
DBAs
Beautifying migration scripts, stored procedures, complex JOINs.
SQL learners
Seeing how a textbook query should be formatted in production style.

Real use cases

  • Your ORM dumped a 400-character one-liner into the slow-query log. Paste it, format, see what columns it actually pulled. Identify the missing index in 30 seconds.
  • A junior dev opened a PR with unformatted SQL. Paste their code into the formatter, copy back, review the readable version. Approve faster.
  • You're documenting a complex report query for stakeholders. Format it with upper keywords + 4-space indent, paste into Notion. Readable for non-engineers.
  • Migration file from another team is messy. Format every statement, commit the clean version. Future you thanks present you.
  • Stack Overflow answer has unformatted SQL. Paste, format, copy -now you can actually read what the solution does.
  • You wrote a query at 2am and woke up unable to follow it. Format, see the structure, debug.

Compared with other tools

FeatureMolixaSqlFormat.orgDBeaver FormatPrettier-sql
Dialects supported5 + auto-detect5 (pick first)ManyMany
Auto-detect dialectYesNoNoNo
Free, no signupYesYes (ads)Desktop installnpm install
Browser-onlyYesServer-sideLocal appBuild step
Keyword case modes32YesYes

Frequently asked questions

Is the SQL formatter free?

Yes. Unlimited use, no signup, no daily cap. Formatting runs entirely in your browser. SqlFormat.org is free but ad-supported and ships single-dialect output; we cover 5 dialects with auto-detection.

Which dialects are supported?

Five: PostgreSQL, MySQL/MariaDB, SQL Server (T-SQL), Oracle (PL/SQL), and SQLite. The auto-detect mode reads syntax cues (RETURNING, TOP n, ROWNUM, LIMIT a,b, autoincrement) and picks the right dialect for you.

Can I uppercase or lowercase keywords?

Yes. Three modes: upper (SELECT FROM WHERE), lower (select from where), or preserve (keep what you typed). Industry style guides usually pick upper for visibility in code reviews.

Will it format minified or one-line queries?

Yes. Paste a 500-character one-liner and the formatter breaks it onto multiple lines at major clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY). Indentation per your spaces setting.

Is my SQL sent anywhere?

No. The tokenizer and formatter run in your browser via pure JS. Your queries -including the table names, column names, and any literal data -stay on your device. No server, no log.

Does it preserve comments?

Yes. Single-line comments (-- like this) and block comments (/* like this */) are kept intact. Comments stay on their own line, attached to the next clause they belong to.

What about stored procedures or triggers?

Single SELECT/INSERT/UPDATE/DELETE statements format cleanly. Multi-statement procedural code (BEGIN ... END blocks) formats but indentation inside the block stays flat. We're a query formatter first, procedure beautifier second.

Why doesn't my JOIN format the way I expected?

We treat JOIN, INNER JOIN, LEFT JOIN, etc. as new-line keywords. The ON clause is also pushed to its own line. If you prefer the JOIN/ON on one line, paste before the JOIN, format, then re-combine.

Does it handle dialect-specific quoting?

Yes. Backticks (`col` in MySQL), square brackets ([col] in SQL Server), double quotes ("col" in PostgreSQL) all pass through unchanged. The tokenizer respects them as identifiers.

Can I get the formatted SQL back as a string?

Yes. The Copy button gets you the formatted SQL on the clipboard. The Download button saves it as .sql. Both work without round-tripping through any server.

Format your SQL now

5 dialects, auto-detect, browser-only. Free unlimited.

Open the SQL formatter

Related developer tools

Built and reviewed bySaqib Zahoor, WeboTech Studio
Last updated:

The SQL Formatter page is built, reviewed, and maintained by the Molixa team. We use the tool we ship and update the docs when the behavior changes.