SQL Minifier — Compress SQL Queries

Paste any formatted SQL query and instantly compress it to a single compact line. This free SQL minifier online removes comments and collapses all whitespace, displaying the exact byte savings and reduction percentage so you know precisely how much space you reclaimed. If your project also includes JSON data payloads or HTML markup, those formatters are available too.

Original: 0 chars Minified: 0 chars Saved: 0 bytes Reduction: 0%
Input SQL
Minified Output

            
Need to format SQL instead? Use our SQL Formatter →

How to Use the SQL Minifier

  1. Paste your formatted or multi-line SQL into the left input panel.
  2. Keep Remove SQL comments checked (default) to strip both -- single-line and /* */ block comments.
  3. Click Minify SQL to compress the query instantly.
  4. Review the stats bar for original size, minified size, bytes saved, and reduction percentage.
  5. Copy the minified result or download it as a .sql file.

Key Features

  • Strips -- single-line comments and /* */ block comments in one pass.
  • Collapses all tabs, newlines, and multiple spaces to a single space.
  • Toggle comment removal on or off to preserve MySQL optimizer hints like /*+ USE_INDEX */.
  • Real-time stats: original character count, minified size, bytes saved, and percentage reduction.
  • Copy minified output to clipboard or download as a .sql file.
  • Handles multiple statements separated by semicolons in a single pass.
  • Runs entirely in your browser — no data leaves your device.

Use Cases

Embed SQL in application configuration files

YAML, JSON, and TOML config files often require SQL to appear on a single line. Paste your formatted query and compress it to one line before embedding it in your app's config or environment variable, keeping comments and formatting in the source file where they belong.

Reduce SQL payload size in API requests

When transmitting raw SQL over REST or GraphQL APIs, every unnecessary byte increases latency. Minifying removes developer comments and extra whitespace that add zero value at runtime, keeping payloads lean.

Strip development comments before production deployment

Stored procedures and migration scripts often include TODO notes and debug comments that should not reach production. Use the SQL whitespace remover to produce a clean, comment-free version ready for deployment.

Compress SQL for storage in database tables or key-value stores

Some architectures store queries in metadata tables or Redis. Minifying reduces storage overhead and makes queries easier to inspect in database UIs that display raw strings without formatting.

Preserve optimizer hints while removing other comments

MySQL optimizer hints like /*+ USE_INDEX(users, idx_email) */ are special comments that must be kept for the query planner to act on them. Uncheck "Remove SQL comments" to only collapse whitespace and leave all comments intact.

FAQ's

No. Removing comments and collapsing whitespace has zero effect on SQL query results. The database engine treats the minified query identically to the formatted original — whitespace is ignored by the SQL parser in all standard contexts.

MySQL optimizer hints use a special comment syntax: /*+ HINT */. When "Remove SQL comments" is checked, these hints will be stripped. If you rely on optimizer hints for query planning, uncheck the option — the minifier will only collapse whitespace and leave all comments intact.

Yes. The minifier processes the entire input at once. Multiple statements separated by semicolons are all compressed into a compact string with semicolons preserved as statement separators.

Modern database engines (MySQL, PostgreSQL, SQL Server) parse SQL almost instantly regardless of whitespace or comments. The performance benefit of minification at the database level is negligible. The real benefits are storage savings in logs and config files, bandwidth reduction when transmitting queries over networks, and cleaner production code.

The minifier will compress stored procedure definitions, but exercise caution: some stored procedure syntax in MySQL with DELIMITER changes depends on newlines for parsing. Always test minified stored procedures in a safe environment before deploying to production.

No. All minification happens entirely in your browser using JavaScript. Your SQL queries never leave your device and are never transmitted to any external server. The tool works fully offline once the page has loaded.

Formatting (beautifying) adds indentation, newlines, and consistent keyword casing to make SQL readable for developers. Minifying does the opposite — it removes all that whitespace to create the smallest possible single-line query for production use. Use the SQL Formatter when you need readability, and the SQL Minifier when you need compactness.

Keeping SQL queries lean and comment-free in production environments is good practice — it reduces log noise, lowers config file sizes, and speeds up the transfer of SQL over network boundaries. This free SQL minifier online handles all of that in a single click, with no server calls and no signup required. The stats bar gives you an exact count of bytes saved so you can track the impact across multiple queries. For teams that maintain both a formatted "source" version and a minified "deployed" version of their SQL, this tool provides the quick conversion step that bridges the two. It's equally useful for solo developers cleaning up a quick script before pasting it into a cron job or deployment pipeline.