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.
🔒 100% in-browser — your SQL never leaves your device.
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?
How do I format PostgreSQL queries?
How do I format SQL Server (T-SQL)?
How do I format Snowflake or BigQuery SQL?
Is my SQL safe with this tool?
What is the difference between formatting and minifying SQL?
Does this tool change what my query does?
What indentation should I use for SQL?
Related Tools
View all tools →Number Base Converter — Binary, Hex, Decimal & Octal
Conversion Tools
Convert between binary, hex, decimal, octal and any base (2-36) instantly. Free, private — all processing in your browser.
Base64 Decoder & Encoder
Encoding & Formatting
Decode and encode Base64 online for free. Real-time conversion with full UTF-8 and emoji support. 100% private — runs in your browser. No signup needed.
Case Converter — UPPERCASE, lowercase, camelCase & More
Text Processing
Convert text between UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE and 6 more formats instantly. Free, browser-only, no signup.
Color Converter — HEX, RGB, HSL & OKLCH
Conversion Tools
Convert HEX to RGB, HSL, OKLCH, OKLAB and CMYK in your browser — copy any format with one click. Free, no signup, your colors never leave the page.
Crontab Generator & Cron Expression Builder
Date & Time
Build, validate, and decode cron expressions in your browser. Live next-run preview in local time or UTC. POSIX 5-field syntax, presets, plain-English description. Free, private, no signup.
CSV to JSON Converter
Encoding & Formatting
Convert CSV to JSON in your browser. RFC 4180, type inference, header row, big-int safe. 100% private, no upload.