SQL Minifier
Free online SQL minifier. Compress SQL queries by removing comments and whitespace. Reduce query size for logs, API requests and embedded SQL. All processing is local and private.
How to Use SQL Minifier
Paste Your SQL
Paste SQL queries into the input panel. The tool accepts SELECT, INSERT, UPDATE, DELETE statements, multi-line queries, and full SQL scripts with comments.
Minify the Query
Click "Minify" to strip comments, whitespace, and unnecessary line breaks. The output is a compact single-line SQL string that executes identically to the original.
Copy the Result
The minified SQL appears in the output panel. Check the size reduction percentage. Use the compressed query in application code, logs, or API requests where compact SQL is preferred.
What Gets Removed
| Removed | Example |
|---|---|
| Line comments | -- this is a comment → removed |
| Block comments | /* multi-line comment */ → removed |
| Indentation | Tabs and spaces at line starts → collapsed |
| Empty lines | Blank lines between clauses → removed |
Frequently Asked Questions
What does SQL minification remove?
SQL minification removes: single-line comments (--), multi-line comments (/* */), unnecessary whitespace (spaces, tabs, line breaks between tokens), and empty lines. It preserves: all SQL keywords, identifiers, string literals, numeric values, and the logical structure of the query. The minified query executes identically to the original — only formatting changes.
Will minification break my SQL?
No. Our minifier is conservative — it only removes characters the SQL parser ignores. String literals (text inside single quotes) are preserved intact. Comments that contain hints for the query optimizer (like /*+ INDEX(...) */) are preserved. The output is functionally identical to the input.
Why would I minify SQL?
Common reasons: embedding SQL in application code where compact format is preferred, reducing log file size when logging queries, sending SQL over API requests where every byte counts, and preparing SQL for storage in version control where diffs are cleaner with consistent formatting. For the opposite operation, use our SQL Formatter to expand and beautify queries.
How much size reduction should I expect?
Typical reduction: 30-50% for well-formatted multi-line queries. Most savings come from removing indentation and line breaks. Simple queries (a single SELECT on one line) see minimal reduction. Complex queries with CTEs, subqueries, and heavy formatting see the largest savings.
SQL Formatting Workflow
SQL goes through different formats in its lifecycle. Write readable, formatted SQL during development. Minify it for embedding in application code or sending over APIs. Validate it before deploying to catch syntax errors. Our suite of SQL tools handles each stage.
- Format: Use SQL Formatter to beautify queries with consistent indentation
- Minify: Compress queries for production use in logs, APIs, and embedded SQL
- Validate: Check syntax with SQL Validator before deploying to production