SQL Formatter & Beautifier

Beautify or minify SQL. Configurable indent, keyword case, and clause formatting — all in your browser.

0 B
0 B

Beautify

Add proper indentation, align keywords, and place clauses on their own lines. Supports CTEs, subqueries, and window functions.

Minify

Strip comments and collapse whitespace. Quoted strings and identifiers are preserved so your query still executes correctly.

Private

Formatting runs in your browser. Your queries — including table names, column names, and business logic — never leave your device.

Why format SQL?

Unformatted SQL is hard to read, review, and debug. A single long line with inconsistent spacing makes it difficult to spot missing JOIN conditions, wrong WHERE predicates, or misplaced GROUP BY columns. A pretty-printed query with consistent indentation makes structural mistakes obvious — an extra level of indentation almost always means a missing closing parenthesis or extra subquery.

When to minify

Minify only the version you embed in application code or log statements — never the version you keep in version control. This tool is useful for one-off cases: a query you're pasting into a JavaScript string, an inline SQL block in a test file, or a quick before/after to see how much whitespace was hiding in a query.

Things the beautifier preserves

SQL comments (-- single-line and /* … */ multi-line) are kept as-is during beautification. Quoted strings and identifiers — used in string literals, table names, and column aliases — are never mangled. The formatter handles ANSI SQL and common dialects including PostgreSQL, MySQL, SQLite, SQL Server, and Oracle.

Frequently asked questions

What does a SQL formatter do?

It rewrites SQL queries so that keywords, clauses, and expressions are properly indented, spaced, and capitalized. The query logic does not change — only whitespace and keyword casing are adjusted.

Beautify vs minify — what's the difference?

Beautify adds line breaks and indentation so queries are readable in editors, documentation, and pull requests. Minify strips comments and collapses whitespace to shrink the query for embedding in code or logs.

Does minifying SQL break anything?

No for well-formed SQL. The minifier preserves quoted strings (string literals, identifiers) and comments. The resulting query executes identically in any database engine.

What indentation options are supported?

Two spaces, four spaces, or a literal tab character. Choose whichever matches your team's SQL style guide.

Can I control keyword case?

Yes. Choose UPPERCASE to make SELECT, FROM, WHERE stand out, lowercase for a subtler look, or preserve to keep the original casing exactly as you typed it.

Will it fix invalid SQL?

No — it formats whatever you paste. If a keyword is misspelled or parentheses are unbalanced, the output will still be invalid, just better-indented. Use a database linter or parser for correctness checking.

Does it understand CTEs (WITH clauses) and window functions?

Yes. CTEs, window functions, OVER/PARTITION BY, and subqueries are all formatted with correct indentation. Recursive CTEs are handled correctly.

Is my SQL sent to a server?

No. Formatting and minification run entirely in your browser. Your queries — including table names, column names, and proprietary business logic — never leave your device.

Can I format a whole SQL file?

Yes. Paste the entire contents of your .sql file into the input area, or drop a .sql file onto the page. The tool handles files of any size that fit in your browser's memory.

Part of our growing tool belt — all client-side, all free.