SQL Minifier

Strip comments and collapse whitespace from SQL without mangling your string literals - free, no signup required.

Input SQL
Minified Output
Original: 0 B Minified: 0 B Saved: 0.0%

SQL Full Form

SQL stands for Structured Query Language - the standard language for relational databases (PostgreSQL, MySQL, SQLite, SQL Server, Oracle, and many more). Well-formatted SQL files are full of comments, indentation, and newlines for readability. Minifying strips those away for situations where you need a compact single-line form.

What this tool does

When you need an SQL minifier

Privacy

Everything runs locally in your browser. Your SQL is never sent to our servers. You can minify queries that contain schema names, PII, or sensitive table structures without them leaving your machine.

Frequently Asked Questions

Will minifying change what my query does?
No - as long as the query doesn't use line comments to split tokens (like hinting /*+ INDEX(t idx) */ in Oracle, which the minifier does strip). Whitespace between keywords is collapsed to a single space; strings and identifiers are untouched. The optimizer sees the same query.
Does it handle string escapes correctly?
Yes. Standard SQL '' escape (a doubled single quote to embed a quote in a string) is preserved. Strings containing --, /*, or newlines are kept intact - the minifier only strips comments outside of string/identifier literals.
What about dollar-quoted strings (PostgreSQL)?
Dollar-quoted strings ($tag$...$tag$) used for PL/pgSQL function bodies are not recognised specially by this simple minifier - the function body will be treated as regular SQL and its whitespace may be collapsed. For function bodies, keep them formatted, or use a server-side tool like pgFormatter.
How much can I realistically save?
Indented, commented SQL typically shrinks by 30-60% depending on how much documentation is inline. The primary benefit is readability in log files and chat messages, not network savings - most SQL is sent over a database connection, not a web request.
Is my SQL uploaded anywhere?
No. All minification happens in your browser. Nothing is sent to our servers, logged, or cached anywhere except the current browser tab. Paste schema-revealing queries without concern.
Can I reverse the minification?
Click Beautify for a light reformat (newlines after semicolons and around braces). For a proper SQL formatter, use a dialect-aware tool like pgFormatter, sqlformat, or your IDE's built-in formatter.