ZIP does not compress files by itself. It is a container that stores each file with a name, sizes, a checksum and a compressed data stream, plus an index at the end. The usual compressor inside is Deflate, a lossless method that never changes the file's bytes. If you want a smaller result, start with how to make a ZIP file smaller and use this guide for the mechanics.
Container first, compressor second
A ZIP archive is a sequence of local file headers followed by compressed data, and a central directory near the end that records where every entry starts. That index is why a viewer can list thousands of files in a moment without decompressing them. Each entry states its compression method, so a single archive can mix stored, Deflate and other methods.
Compression is applied to each file separately, not to the archive as one stream. This is a deliberate design choice: you can extract one file without reading all the others, and you can change one entry without rewriting everything. It also means a file that does not compress well cannot be offset by one that does.
ZIP64 changes how sizes and offsets are recorded, not how compression works. A 5 GB entry uses the same Deflate algorithm as a 5 KB one.
What Deflate actually does
Deflate, defined in RFC 1951, combines two ideas. First, LZ77 replaces repeated sequences with short references to earlier data: instead of writing the same phrase twice, it writes the phrase once and a pointer the second time. Second, Huffman coding gives frequent symbols shorter bit patterns and rare ones longer patterns. Both steps are reversible, so extraction reproduces the original bytes exactly.
| Input | Why Deflate helps | Typical outcome |
|---|---|---|
| Source code, JSON, CSV, logs | Many repeated words, keys and formatting characters | Often 50-80% smaller |
| Plain text documents | Repeated letters and common words | Usually much smaller |
| Uncompressed bitmaps | Large runs of similar pixels | Often much smaller |
| JPEG, MP4, MP3, PNG, PDF, DOCX | Already compressed by their own formats | Little or no change |
The percentages above are typical for those kinds of content, not measurements of Aback ZIP. Actual results depend entirely on your data.
Compression levels are a time trade
Deflate levels run from 0 to 9. Level 0 stores data without searching for matches; level 1 is fast; level 6 is the usual default; level 9 searches hardest. Higher levels look for more distant and more subtle repetitions, which costs CPU time and usually yields only a few percent over the default. On a mixed archive, the difference between 6 and 9 is often smaller than the effect of removing a single unnecessary file.
zip -0 archive.zip files/ # store only, fastest
zip -6 archive.zip files/ # balanced default
zip -9 archive.zip files/ # maximum search, slowestCreate ZIP exposes the same choice in plain language: Store, Fast, Balanced and Maximum. Its smart default stores already-compressed formats rather than spending time on them, and no entry is ever allowed to grow.
Every level is lossless. An archive built at level 0 and one built at level 9 extract to byte-for-byte identical files; only the archive size and build time differ.
Other methods you may find in a ZIP
Deflate is the common choice, but the format allows other methods. Aback ZIP can decode BZIP2, LZMA, XZ and Zstandard entries and write ZIPs with Store or Deflate. Deflate64 and PPMd entries are recognised and copied unchanged by split, merge, edit and clean, but they are not decompressed.
| Method | ID | Aback ZIP |
|---|---|---|
| Store | 0 | Read and write |
| Deflate | 8 | Read and write |
| Deflate64 | 9 | Listed and copied as-is, not decompressed |
| BZIP2 | 12 | Decoded |
| LZMA | 14 | Decoded |
| Zstandard | 93 | Decoded |
| XZ | 95 | Decoded |
| PPMd | 98 | Listed and copied as-is, not decompressed |
Compress ZIP recompresses entries that can benefit and keeps the smaller version, with an honest before-and-after report. ZIP Viewer shows the method used by every entry if you want to know what you are dealing with.
Compression is not integrity or secrecy
- Integrity: a CRC-32 is stored for each entry so a reader can notice accidental corruption. It is not a cryptographic hash and proves nothing about authenticity.
- Encryption: compression is not encryption. A Deflate stream is readable by anyone; add AES-256 or ZipCrypto protection explicitly if the contents are sensitive.
- Order: compressing each entry separately means a corrupted file does not necessarily make the rest of the archive unreadable.
- No transformation of file contents: a JPEG stays a JPEG. ZIP never decodes and re-encodes your photos, videos or documents.
For the exact layout of headers, extra fields and the central directory, see inside a ZIP file, byte by byte.
Why 7-Zip can be smaller
Formats such as 7z use newer compressors and can treat the archive as one stream, letting them share dictionaries across files. That often beats ZIP on large sets of similar files. The cost is compatibility: Windows, macOS and Linux file managers open ZIP natively but need extra software for 7z. ZIP vs 7Z compares the two, and the choice usually comes down to whether the recipient can open the result.
A tiny LZ77 example
Imagine a line that repeats the phrase error: connection reset twenty times. LZ77 does not remember the whole alphabet or keep a dictionary of words; it keeps a sliding window of recently decoded bytes. On the second occurrence it can emit a pair meaning "go back N bytes and copy M bytes" instead of writing the phrase again. The decoder already has those bytes, so it can reproduce them exactly.
input: error: connection reset | error: connection reset
output: "error: connection reset" <back 24, copy 23>Huffman coding then looks at the symbols that remain, which include literal bytes and the copy references. Frequent symbols get short bit patterns; rare ones get longer patterns. Together the two stages are what Deflate specifies. A level 1 compressor uses a smaller window and simpler matching, while level 9 searches farther back and tries more candidates. Both produce a valid Deflate stream that any ZIP reader can decode.
- The window is limited. Deflate looks back at most 32 KB, so repetition farther apart than that cannot be shared.
- Copy references are cheap only when the match is long enough. A two-byte repeat costs more to describe than to write literally.
- The output is a bitstream, not bytes aligned to a boundary. That is why a compressed entry needs its exact compressed size recorded in the header.
- Nothing is guessed or approximated. Decompression restores the original bytes, which is why a CRC-32 check at the end is meaningful.
This also explains why already-compressed formats resist a second pass. A JPEG's bytes are the output of a different compressor and look statistically random to Deflate; there are no long repeats left for the sliding window to exploit.
The example above is illustrative, not literal Deflate output. Real streams include block headers, length and distance codes, and Huffman tables.