Skip to content

SQL Formatter & Beautifier

Format, beautify and minify SQL instantly in your browser. Supports PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, Oracle & SQLite. Free, private — your SQL never leaves your device.

No Tracking Runs in Browser Free
Indent
Formatted SQL

🔒 100% in-browser — your SQL never leaves your device.

Reviewed for dialect-correct formatting and comment-safe minification — Go Tools Engineering Team · Jun 3, 2026

What is SQL Formatting?

SQL formatting (also called beautifying or pretty-printing) rewrites a query with consistent indentation, line breaks and keyword casing so its structure is easy to read. The query runs identically before and after — only the whitespace changes. Formatting makes long queries reviewable in pull requests, easier to debug, and consistent across a team. Minifying does the reverse: it strips comments and collapses the query to a single compact line for embedding in code or logs.

Key Features

9 SQL dialects

PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, Snowflake, Oracle (PL/SQL), SQLite, MariaDB and Standard SQL.

Format and minify

Beautify for readability or compress to a single line — comments are safely stripped on minify.

100% private

All processing happens in your browser. Your SQL is never sent to a server.

Style controls

Choose keyword casing and 2-space, 4-space or tab indentation.

Examples

Messy SELECT with JOIN

select u.id,u.name,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=true group by u.id,u.name order by orders desc

Indent a one-line query with a JOIN, aggregate and GROUP BY into a readable layout.

Nested subquery

select * from products where category_id in (select id from categories where parent_id=(select id from categories where slug='electronics')) and price between 100 and 500

Break out nested subqueries so each level of logic is visible.

CTE (WITH clause)

with recent as (select user_id,max(created_at) last_seen from sessions group by user_id) select u.email,r.last_seen from users u join recent r on r.user_id=u.id where r.last_seen> now() - interval '7 days'

Format a Common Table Expression with a downstream join.

Bulk INSERT

insert into logs(level,message,created_at) values('info','started',now()),('warn','slow query',now()),('error','timeout',now())

Align multi-row INSERT values for easier review.

Common Use Cases

Code review
Format queries before opening a pull request so reviewers see clean, consistent SQL.
Debugging
Beautify a one-line query copied from a log or ORM to spot the problem fast.
Documentation
Produce neatly indented SQL examples for runbooks and tech docs.
Embedding
Minify a query to a single line before inlining it in application code or config.

Technical Details

Dialect-aware parsing
Built on the sql-formatter engine, which understands dialect-specific syntax, quoting and functions.
Browser-based
Runs entirely client-side; no SQL ever leaves your device or hits a server.
Comment-safe minify
Minification strips line and block comments and preserves quoted string literals exactly.

Best Practices

Pick the right dialect
Choosing your actual database avoids mis-formatting dialect-specific syntax like backticks or T-SQL brackets.
Standardize keyword casing
Agree on UPPERCASE keywords across the team for consistent diffs.
Don't minify what you'll edit
Keep formatted SQL in source files; minify only for embedding or transport.

Frequently Asked Questions

How do I format SQL online?
Paste your SQL into the input box, choose your database dialect, and click Format. The tool reindents the query with consistent line breaks and keyword casing, then lets you copy it. Everything runs locally in your browser — nothing is uploaded.
How do I format PostgreSQL queries?
Select PostgreSQL from the dialect dropdown before clicking Format. This makes the formatter respect PostgreSQL-specific syntax such as dollar-quoted strings, casts (::), and functions, producing correct, idiomatic output.
How do I format SQL Server (T-SQL)?
Choose "SQL Server (T-SQL)" as the dialect. The formatter then understands T-SQL constructs like bracketed [identifiers], TOP, and variables, so they are indented and cased correctly.
How do I format Snowflake or BigQuery SQL?
Both are in the dialect dropdown. Selecting Snowflake or BigQuery applies their respective parsers so warehouse-specific functions and syntax format cleanly instead of being mangled by a generic SQL parser.
Is my SQL safe with this tool?
Yes. All formatting and minifying happen locally in your browser using JavaScript — your queries are never sent to any server, logged, or stored. This makes it safe to use with production schemas and proprietary queries, unlike server-side formatters that receive a copy of everything you paste.
What is the difference between formatting and minifying SQL?
Formatting (beautifying) adds indentation and line breaks to make a query readable. Minifying does the opposite: it removes comments and collapses the query to a single compact line, useful for embedding SQL in code or reducing log noise. Both produce queries that run identically to the original.
Does this tool change what my query does?
No. Formatting and minifying only change whitespace, line breaks, comments and keyword casing — never the logic. The formatted query returns exactly the same results as the original.
What indentation should I use for SQL?
Two spaces is the most common default and keeps diffs compact; four spaces improves readability for deeply nested queries; tabs let each developer view their preferred width. Pick one and apply it consistently across your team — this tool supports all three.

Related Tools

View all tools →