SQL Minifier

Compress your SQL queries by removing whitespace, comments, and formatting instantly.

Input SQL
Minified Output
Minified output will appear here...
info

About SQL Minifier

SQL Minifier is a free online tool that compresses SQL queries by removing all comments, indentation, line breaks, and redundant whitespace. The output is a compact single-line version of your query that is byte-for-byte functionally identical — every clause, keyword, and value is preserved, only the decoration is gone.

The tool is designed for situations where formatted SQL creates friction: hardcoding a query inside an ORM string or a configuration file, shrinking a query before storing it in an audit log, reducing the size of SQL files shipped as part of a build artifact, or trimming queries that are repeatedly transmitted over a low-bandwidth connection. Unlike an SQL formatter — which adds indentation and newlines to aid readability — a minifier does the opposite, trading visual clarity for density.

All processing runs entirely in your browser using JavaScript. No SQL is uploaded, stored, or sent to a server at any point. You can safely minify queries that contain sensitive table names, column values, or business logic. The tool is free, requires no account, and imposes no size limits.

star

Key Features

check_circle

Removes both comment styles

Both single-line (-- comment) and block (/* comment */) SQL comments are stripped, so documentation-heavy migration scripts shrink significantly.

check_circle

Collapses all whitespace

Newlines, tabs, and runs of multiple spaces are each reduced to a single space, compacting multi-line formatted queries into a single dense line.

check_circle

Live size savings readout

After minification a stats bar shows original character count, minified character count, and percentage saved so you know exactly how much space was reclaimed.

check_circle

File upload and download

Load a .sql or .txt file directly from disk and download the minified result as minified.sql — no copy-paste required for larger query files.

check_circle

100% client-side and private

Minification happens locally in your browser. Queries containing sensitive schema names, credentials in connection strings, or proprietary business logic never leave your machine.

check_circle

Handles multiple statements

Paste a script with several SELECT, INSERT, or CREATE statements separated by semicolons and all of them are minified together in one pass.

help

How to Use

01

Paste Your SQL

Copy your formatted SQL queries and paste them into the input editor on the left.

02

Minify

Click "Minify" to strip all comments, whitespace, and line breaks from your SQL.

03

Copy the Result

Review the size savings, then copy the minified SQL or download it as a .sql file.

code_blocks

Example

A formatted SELECT with comments and indentation is collapsed into a single line. Both the -- single-line comment and the block comment are removed, and all whitespace runs are reduced to one space.

Formatted SQL input
-- Fetch top customers
SELECT
    c.id,
    c.name,
    SUM(o.amount) AS total
FROM customers c
/* join orders */
INNER JOIN orders o ON c.id = o.customer_id
WHERE o.status = 'completed'
GROUP BY c.id, c.name
ORDER BY total DESC
LIMIT 10;
Minified SQL output
SELECT c.id, c.name, SUM(o.amount) AS total FROM customers c INNER JOIN orders o ON c.id = o.customer_id WHERE o.status = 'completed' GROUP BY c.id, c.name ORDER BY total DESC LIMIT 10;
lightbulb

Common Use Cases

  • arrow_circle_right

    Embedding SQL in application code

    When a query is stored as a string literal inside Python, Java, or JavaScript source code, multi-line formatting adds noise and can break templating. Minifying first produces a clean one-liner that is safe to embed without escaping newlines.

  • arrow_circle_right

    Shrinking SQL in audit logs and telemetry

    Logging systems often record executed queries. Minified queries use less disk space per log line and are easier to grep or index, especially when thousands of queries are written per minute.

  • arrow_circle_right

    Reducing SQL migration file sizes

    Database migration scripts can grow into thousands of lines of commented DDL. Minifying them reduces the file size shipped in build artifacts or stored in version-controlled migration directories.

  • arrow_circle_right

    Transmitting queries over constrained channels

    Some systems pass SQL through query-string parameters, message queues, or narrow API fields that impose character limits. A minified query often fits where a formatted one does not.

  • arrow_circle_right

    Stripping comments before sharing externally

    Developer comments inside SQL often contain internal table aliases, schema notes, or business logic explanations. Minifying removes all comments in one step before pasting a query into a public forum, bug report, or support ticket.

quiz

Frequently Asked Questions

What is SQL Minification? expand_more
SQL minification removes unnecessary whitespace, line breaks, indentation, and comments from SQL queries without changing their meaning or execution. The result is a compact single-line query that is functionally identical to the original.
Will minifying change how my query executes? expand_more
No. SQL engines ignore whitespace and comments when parsing queries. The minified output produces identical execution plans and results as the formatted original.
Is my SQL secure? expand_more
Yes. All minification runs entirely in your browser using JavaScript. Your queries never leave your machine and are not sent to any external server.
Does this remove both comment styles? expand_more
Yes. The minifier removes both single-line comments (-- style) and block comments (/* */ style) from your SQL queries.
How is SQL Minifier different from SQL Formatter? expand_more
SQL Formatter and SQL Minifier are opposite tools. SQL Formatter adds indentation, newlines, and consistent keyword casing to make a query easier for humans to read. SQL Minifier does the reverse — it removes all that formatting to make the query as compact as possible for machines. Use the formatter during development and the minifier when preparing queries for production systems, log storage, or code embedding.
How is this different from JSON Minifier or HTML Minifier? expand_more
Each minifier is language-specific. JSON Minifier removes whitespace from JSON data structures. HTML Minifier compresses markup including optional closing tags and attribute quotes. SQL Minifier understands SQL comment syntax (-- and /* */) and collapses SQL-specific whitespace patterns. Do not run SQL through a JSON or HTML minifier as the output would likely be corrupted.
Can I minify multiple SQL statements at once? expand_more
Yes. Paste a script containing multiple statements separated by semicolons and all of them are processed together in a single pass. The semicolons and all statement content are preserved.
Is there a size limit? expand_more
There is no fixed limit. Because everything runs locally in your browser, you can process large migration scripts or query files — performance depends only on your device memory.