Make ZIP files smaller with ZIP Shrinker

Hacker News Top Tools

Summary

ZIP Shrinker is a browser tool that reduces ZIP file sizes by recompressing with libdeflate, removing metadata and directory entries, and works with formats like APK and EPUB.

No content available
Original Article
View Cached Full Text

Cached at: 05/19/26, 07:01 AM

# Make ZIP files smaller with ZIP Shrinker Source: [https://evanhahn.com/make-zip-files-smaller-with-zip-shrinker/](https://evanhahn.com/make-zip-files-smaller-with-zip-shrinker/) I built ZIP Shrinker, a little browser tool to shrink ZIP files\. It also works with formats that are secretly ZIPs underneath, like APK, EPUB, JAR, and many more\. [Try it out\!](https://evanhahn.com/uploads/2026-05-16-zip-shrinker/) ## How does it work? At a high level, this tool \(1\) re\-compresses every file in the ZIP archive with higher compression \(2\) removes all metadata \(3\) removes entries for directories\. ### Re\-compressing ZIP files are typically compressed with an algorithm called[Deflate](https://zlib.net/feldspar.html)\. There are a few tools that can re\-compress Deflate data and make it smaller, usually by spending more time on the computation\. I took one of these tools,[libdeflate](https://github.com/ebiggers/libdeflate), and applied it to each compressed entry in the ZIP\. I chose libdeflate because of its performance; alternatives like[Zopfli](https://github.com/google/zopfli)can achieve marginally smaller results but take*much*longer\. I created[libdeflate\.js](https://codeberg.org/EvanHahn/libdeflate.js), a WebAssembly wrapper for libdeflate, as part of this work\. \(I always relish my time working with WASM\!\) ### Removing metadata and directories Each entry in a ZIP file can contain additional metadata like comments\. These aren’t typically used, and if they’re there, my shrinker removes them\. This usually doesn’t save too many bytes, but it doesn’t hurt\. Removing directories is a slightly spicier decision\. Usually, the existence of a file entry implies the existence of the directory it’s inside\. For example,`foo/bar\.txt`implies the existence of the`foo`directory\. Some ZIPs include separate entries for directories, but because most extractors don’t need them, I remove those\. This has the side effect of removing empty directories—[let me know](https://evanhahn.com/contact/)if that’s a problem for you\. If you want to see how the whole project works,[check out the full source code](https://codeberg.org/EvanHahn/zip-shrinker)\. ## How good is it? I tested several ZIPs to see what this tool could do\. Some anecdotal results: FileSavingsLinux v6\.19 source15\.8 MiB \(5\.62%\)Romeo & Juliet EPUB from Project Gutenberg51\.2 KiB \(18\.16%\)Signal for Android v8\.3\.4 \(APK\)25\.6 MiB \(30\.06%\)Not particularly scientific, but useful to see\. ## Why did I do this? This proof\-of\-concept shows that you can make ZIP files smaller without sacrificing backwards compatibility\. It could be useful for sending an archive to someone, but could also be useful to reduce bandwidth and server costs\. For example, if Project Gutenberg re\-compressed all their EPUB books with this method, they might be able to save some money\. Of course, ZIP isn’t always the most efficient format\. Typically, other archives like`\.tar\.bz2`can be smaller\. But those aren’t backwards\-compatible\! ZIP also supports compression methods other than Deflate\. They’re atypical, but you could use them to achieve a smaller result, too\. [Give my tool a try](https://evanhahn.com/uploads/2026-05-16-zip-shrinker/)if you want a smaller ZIP\.

Similar Articles

bzip3

Hacker News Top

BZip3 is a high-performance compression tool that offers superior compression ratios and speed compared to its predecessor BZip2, utilizing advanced algorithms like context mixing entropy coding and Burrows-Wheeler transform.

GetCompress

Product Hunt

GetCompress is a tool for lossless media compression without context switching.