all tools
⬡ DEVELOPER

SQL Formatter & Beautifier

Format, highlight, and minify SQL. Runs entirely in your browser.

Input SQL
Formatted SQL
Formatted output will appear here
ready

What This Tool Does

Paste 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.

Common SQL Patterns

PatternExample
Basic SELECTSELECT id, name, email FROM users WHERE active = 1
JOIN querySELECT u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id
AggregationSELECT department, COUNT(*) AS total, AVG(salary) FROM employees GROUP BY department HAVING COUNT(*) > 5
SubquerySELECT * FROM products WHERE price > (SELECT AVG(price) FROM products)
INSERTINSERT INTO logs (user_id, action, created_at) VALUES (42, 'login', NOW())
UPDATEUPDATE users SET last_login = NOW(), login_count = login_count + 1 WHERE id = 42

Frequently Asked Questions

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 tools