
Compress SQL files and database dumps safely
SQL files come in two kinds. Scripts, like migrations, stored procedures, and schema files, are mostly code and comments, and minifying them removes a useful chunk. Database dumps from mysqldump, pg_dump, or SQL Server are mostly data, and the way to shrink them is real compression: a 25 MB dump typically gzips to under 2 MB. This tool does both. It removes comments and extra whitespace without changing a single piece of SQL, then packs the result as .sql.gz or .zip.
Everything runs in your browser. Your schema and data are never uploaded.
How to use it
- Paste SQL, open a
.sqlfile, or drag one onto the tool. - Check the detected database type. Change it if it's wrong, since string rules differ between databases.
- Choose readable or compact output. Results update automatically.
- Download as
.sql.gz(best for dumps),.zip, or plain.sql.
Why simple SQL minifiers break dumps
Removing "anything that looks like a comment" is dangerous in SQL. Real dumps contain several things that look like comments or whitespace but aren't:
| Looks like | Actually is | How it's handled |
|---|---|---|
/*!40101 SET NAMES utf8mb4 */ | A MySQL command that runs on import. Every mysqldump file is full of them, and they control character sets and foreign key checks. | Kept exactly |
/*+ INDEX(t idx) */ | An optimizer hint in Oracle, MySQL, and others | Kept exactly |
Tab-separated lines after COPY … FROM stdin; | PostgreSQL table data, where every tab and space is part of a value | Kept byte for byte, through the closing \. |
'50% -- off' | A string that happens to contain -- | Kept, since strings are read exactly as the database reads them |
$$ … $$ | A PostgreSQL function body | Kept exactly, including its own comments and line breaks |
DELIMITER ;;, GO, \connect | Client commands that must stay on their own line | Kept on their own lines |
String rules also differ between databases. In MySQL, 'It\'s' is one string, because a backslash escapes the quote. In PostgreSQL, a backslash is an ordinary character, so 'C:\' is a complete string. The tool detects the database from telltale features and applies the right rules. You can override it if needed.
Verified, token by token
After compressing, the tool reads its own output again with the same rules and checks that every keyword, name, number, string, and operator is identical to the original, in the same order. The green Verified badge means only comments and whitespace changed. During development, randomized scripts with tricky strings, triggers, views, and comments were run in SQLite before and after compression, and all 720 runs produced identical databases.
Frequently asked questions
Will the compressed SQL run the same?
Yes. Only comments and whitespace between tokens are removed, and the code itself is verified as identical. MySQL version comments, optimizer hints, and dump data are always kept.
Is my file uploaded?
No. Parsing, compressing, and verifying all happen in your browser.
How do I import a .sql.gz file?
For MySQL, run gunzip < dump.sql.gz | mysql dbname. For PostgreSQL, run gunzip -c dump.sql.gz | psql dbname. phpMyAdmin and most hosting control panels also accept .sql.gz uploads directly.
Why did my dump barely shrink when minified?
Dumps are mostly data, and the tool never changes data. That's normal. The gzip download is where the savings are, often 90 percent or more.
Readable or compact?
Readable keeps single spaces and puts each statement on its own line, which is easier to review and diff. Compact removes every space the database doesn't need. Both run identically.
How large a file can it handle?
A 25 MB dump with 2.4 million tokens took about three seconds in testing. Work happens in a background thread, so the page stays responsive.
