Strip comments and whitespace from SQL — collapse to one compact line, string literals stay untouched, runs entirely in your browser.
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Minified SQL appears here.What this tool does
A SQL minifier that shrinks a query without changing what it does. It removes `--` line comments and `/* … */` block comments, collapses every run of spaces, tabs and newlines down to a single space, and (optionally) folds the whole script onto one line so it drops cleanly into a string constant, a log line, or a JSON payload. The hard part of minifying SQL is knowing what NOT to touch: anything inside a single-quoted string, a double-quoted or backtick identifier, a T-SQL `[bracket]` name, or a PostgreSQL `$tag$ … $tag$` dollar-quoted block is data, so a `--` or run of spaces in there is left exactly as written — including the doubled `''` escape. The result executes identically to the query you pasted; the only thing that changes is the byte count. This is the inverse of the SQL Formatter: format to read, minify to ship. Everything runs client-side, so a query full of table names or PII never leaves the tab, and a live byte/character readout shows you exactly how much you saved.
Tool details
- Input
- Text + Structured content
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 7 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How SQL Minifier fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 SQL Formatter Format and beautify SQL — supports MySQL, PostgreSQL, BigQuery, SQLite and 17 more dialects. Open
- 2 JS Minifier Minify JavaScript — strip comments, whitespace, optional name shortening. 40-70% smaller. Open
- 3 SQL Cheatsheet SQL cheat sheet — 100+ statements covering SELECT, JOIN, window functions, indexing, MySQL/PostgreSQL/SQLite differences. Open
Real-world use cases
Embed a query as a string constant in application code
You have a 30-line formatted query you want to inline as a string in a Go, Python or Node file. Pasted as-is, the multi-line indentation fights with your code's own indentation and the comments leak into source control noise. Minify with "Collapse to single line" on, copy the result, and you get one tidy line that drops into a `const QUERY = "…"` with no awkward line-continuations. The query still runs identically — you just traded readability you don't need at runtime for a clean diff.
Shrink a query before it goes into a log or trace
Observability tools bill by ingested bytes and truncate long lines. A query logged with full pretty-print indentation wastes a third of its bytes on whitespace and gets cut off mid-statement in the trace viewer. Minify it first: comments gone, whitespace collapsed, the whole statement on one line that the log viewer shows in full. You still capture the exact SQL that ran, just without the cosmetic padding.
Send SQL over a size-constrained transport
When a query travels in a URL query param, a webhook payload, or a message-queue body, every byte counts and some transports cap the length. Minifying first reclaims the 20–40% that comments and indentation typically add, and because string literals are protected, a `WHERE note = 'a -- b'` clause survives the trip intact.
Compare two queries by their semantics, not their formatting
Two engineers wrote the "same" query but one used tabs and the other spaces, one capitalised keywords and the other didn't, and one left a `-- TODO` comment in. A line-by-line diff lights up everywhere even though the SQL is identical. Minify both and diff the minified output: if the bytes match, the queries are the same statement; if they differ, the diff now points at a real semantic difference instead of whitespace noise.
Keep comments but kill the indentation for a migration file
A migration carries a license header and a `/*+ INDEX(...) */` planner hint that must survive, but the hand-formatted indentation is just bulk. Untick "Strip comments", leave "Collapse to single line" off, and you get one compact statement per line with the meaningful comments intact — smaller than the formatted source, still legible in the migration history.
Common pitfalls
Assuming minified SQL is somehow "faster" to execute. The database parses both forms into the same plan; minifying changes transfer/storage size and parse-string length, not query performance. Use it to save bytes, not to speed up the engine.
Minifying the query you keep in version control. Once it is one line with no comments, the next person to edit it has to re-format it by hand and loses your `-- why` notes. Keep the readable copy in the repo; minify only the embedded/transmitted copy.
Pasting a dialect whose comment syntax differs. This tool handles standard `--` and `/* */`; MySQL's `#` line comment is NOT treated as a comment, so a `# note` line is kept verbatim. If you rely on `#` comments, convert them to `--` first or leave "Strip comments" off.
Privacy
The minifier is plain JavaScript that tokenizes and rewrites your SQL inside the browser tab — no query, table name, or literal value is ever sent to a server, and there is no logging of what you minify. One caveat: the "share" URL encodes your input in the query string (`?sql=…`), so if you paste a share link containing a production query into Slack or email, that text lands in the destination server's access log. For a one-off that is fine; for SQL with embedded secrets or PII, copy the minified output manually instead of sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only