SQL Formatter & Beautifier
Format, highlight, and minify SQL. Runs entirely in your browser.
Formatted output will appear hereFormat, highlight, and minify SQL. Runs entirely in your browser.
Formatted output will appear herePaste any SQL query — minified API output, a one-liner from a log file, or a hand-written query with inconsistent spacing — and the formatter rewrites it with proper indentation, uppercased keywords, and newlines before each major clause. SELECT columns are listed one per line. WHERE conditions are indented under the clause. JOIN types stay at the left margin. Switch to Minify mode to do the reverse: collapse everything to a single compact line for use in code strings or API payloads.
| Pattern | Example |
|---|---|
| Basic SELECT | SELECT id, name, email FROM users WHERE active = 1 |
| JOIN query | SELECT u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id |
| Aggregation | SELECT department, COUNT(*) AS total, AVG(salary) FROM employees GROUP BY department HAVING COUNT(*) > 5 |
| Subquery | SELECT * FROM products WHERE price > (SELECT AVG(price) FROM products) |
| INSERT | INSERT INTO logs (user_id, action, created_at) VALUES (42, 'login', NOW()) |
| UPDATE | UPDATE users SET last_login = NOW(), login_count = login_count + 1 WHERE id = 42 |
What does an SQL formatter do?
An SQL formatter takes raw or minified SQL queries and rewrites them with consistent indentation, line breaks, and keyword casing. This makes long queries readable at a glance: SELECT columns appear on separate lines, WHERE conditions are indented, and JOIN clauses are aligned at the left margin.
Why should SQL keywords be uppercase?
The SQL standard does not require uppercase, but the convention is universal across database engines, documentation, and ORMs. Uppercase keywords (SELECT, FROM, WHERE) visually separate structural tokens from identifiers and string values, making it much easier to scan a query for its logical structure.
Does formatting SQL change how the database executes it?
No. SQL is whitespace-insensitive. A minified single-line query and a beautifully formatted multi-line query produce identical query plans in every major database — PostgreSQL, MySQL, SQLite, SQL Server, and Oracle alike. Formatting is purely cosmetic.
What is SQL minification?
Minification strips all unnecessary whitespace and comments from a query, collapsing it to a single line. This is useful when embedding SQL in code strings, transferring queries over the wire, or storing them in configuration files where whitespace is irrelevant and compactness matters.
Is my SQL sent to any server?
No. This tool runs entirely in your browser using JavaScript. Your SQL never leaves your machine. There are no API calls, no logging, and no server-side processing of any kind.
Which SQL dialects does this formatter support?
The formatter handles standard ANSI SQL constructs — SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, JOIN types, GROUP BY, ORDER BY, HAVING, CASE/WHEN, and common aggregate functions. Dialect-specific syntax (PostgreSQL dollar-quoting, SQL Server square brackets, MySQL backticks) is preserved as-is without modification.
More developer tools
JSON formatter, JWT decoder, regex tester, Base64 encoder, and more.
Browse all toolsFeatured
Word Counter
Live word count, character count, sentence count, paragraph count, and reading time estimate as you type. Useful for blog posts, tweets, essays, and any platform with a character limit.
QR Code GeneratorPassword GeneratorJSON Formatter & DiffImage CompressorColor Picker & PalettePomodoro TimerLorem Ipsum GeneratorPercentage CalculatorBase64 Encoder / DecoderSee AllWord Counter
Live word count, character count, sentence count, paragraph count, and reading time estimate as you type. Useful for blog posts, tweets, essays, and any platform with a character limit.
QR Code Generator
Generate QR codes for URLs, plain text, WiFi credentials, or vCard contact info. Set size, foreground/background color, and error correction level. Download as PNG or SVG.
Password Generator
Generate strong passwords with configurable length (8–128), and toggles for uppercase, lowercase, numbers, and symbols. Strength meter, one-click copy. Runs entirely in the browser.
JSON Formatter & Diff
Paste raw or minified JSON to format, validate, and syntax-highlight it. Switch to diff mode to compare two JSON blobs side by side and see exactly what changed.
Image Compressor
Drag and drop JPG, PNG, or WebP images and compress them entirely in-browser using the Canvas API. Shows original vs compressed size and savings percentage. Nothing uploaded anywhere.
Color Picker & Palette
Full-featured color picker with HEX, RGB, HSL, and CMYK output. Upload an image to extract the 5 dominant colors as a palette. Copy any value with one click.