SQL Minifier
Compress your SQL queries by removing whitespace, comments, and formatting instantly.
Minified output will appear here...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.
Key Features
Removes both comment styles
Both single-line (-- comment) and block (/* comment */) SQL comments are stripped, so documentation-heavy migration scripts shrink significantly.
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.
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.
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.
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.
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.
How to Use
Paste Your SQL
Copy your formatted SQL queries and paste them into the input editor on the left.
Minify
Click "Minify" to strip all comments, whitespace, and line breaks from your SQL.
Copy the Result
Review the size savings, then copy the minified SQL or download it as a .sql file.
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.
-- 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; 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; 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.