← Back to BlogWhat Is a ZIP File? Packing, Compression and the Myths Around It
2026-10-12
A ZIP file is a container and a compression format in one. Every member inside is compressed on its own, and a directory listing at the end tells whatever opens it the name of each member, which byte it starts at and how it was stored. Two things follow from that structure: single members can be added or removed without rebuilding the archive, and some payloads barely shrink once they are inside.
What happens when files get zipped
- The usual method is DEFLATE: a sliding window replaces repeated strings with a reference saying how far back and how long the match was, then a Huffman pass encodes symbols by frequency.
- Each member is compressed independently, so removing one does not force a rebuild of the rest. The trade-off is that identical blocks shared between two files cannot be exploited.
- A central directory sits at the end of the file carrying names, offsets and checksums, which is why a reader can open one member without touching the others.
- There is more than one storage method; stored means packed as-is with no compression attempt, which is what happens to content that will not shrink.
- Formats such as 7Z and RAR use different containers, and ZIP is the one every operating system opens out of the box.
Why photos barely shrink inside a ZIP
This is the part people misjudge most often. ZIP looks for repeated byte sequences, and JPEG, WebP, AVIF and MP4 have already been through entropy coding, leaving output that is close to random. A folder of photographs commonly comes out one to three percent smaller, and occasionally slightly larger once headers and the directory are added.
- JPEG, WebP, AVIF and PNG have already been compressed once. PNG uses DEFLATE itself, so zipping a PNG adds almost nothing.
- What does shrink is anything with redundancy left in it: CSV, logs, uncompressed BMP and TIFF, raw SVG files often drop by more than 70 percent.
- To make a JPEG or PNG smaller, re-encode it rather than archive it. The trade-offs are set out in /blog/lossy-vs-lossless-compression.
- Moving PNG to WebP or AVIF usually halves the size at the same quality, which no amount of zipping will do.
- In a mixed bundle of HTML, CSS and images the text parts shrink noticeably and the image parts stay put.
Beyond packing: encryption, checksums and size limits
- There are two generations of encryption. Legacy ZipCrypto has known practical attacks, so anything with a password should use AES-256.
- Every member carries a CRC32 value, which detects corruption in transit. It is a check against errors, not a defence against tampering.
- The original format caps individual files and the archive at 4 GB. The ZIP64 extension lifts that, and modern readers support it by default.
- Split archives are one archive cut into pieces. Every piece has to be present before any member can be extracted.
- File name encoding is a legacy trap: pack in UTF-8, otherwise non-Latin names can come out as garbage on another platform.
When to reach for ZIP, and when not to
- A batch of documents, spreadsheets or logs going out at once: pack them, since email handles one attachment more gracefully than twelve.
- Hundreds of photographs for a print shop: packing is fine, but do not expect shrinkage. Compress the images first, and a batch routine is in /blog/batch-compress-images-multiple.
- An attachment bouncing off a 10 MB mail limit: compress the images first, then pack. Doing it the other way round changes almost nothing, see /blog/compress-image-for-email-attachments.
- A single image that needs to be smaller: do not archive it, re-encode it. The distinction is covered in /blog/compressed-vs-resized-image.
- Long term archives: choose the open ZIP format with stored or standard DEFLATE entries rather than something that needs a specific decompressor.
Packing and compressing are two separate jobs, and treating them as one is where the wrong expectations come from. The trade-offs sit in /blog/lossy-vs-lossless-compression, re-encoding a PNG without visible damage in /blog/compress-png-without-losing-quality, and the pack-after-compress email flow in /blog/compress-image-for-email-attachments.
FAQ
Does a ZIP always make files smaller?
No. Content that has already been compressed has little redundancy left, particularly JPEG and MP4. An archive occasionally comes out a touch larger because of headers and the directory.
Why did some file names turn into garbage after extracting?
The archive was written with a non UTF-8 name encoding and the other system read it with its own default. Repacking with UTF-8 filenames fixes it.
Is an encrypted ZIP secure enough?
It depends on the generation. Legacy ZipCrypto has practical attacks and only stops casual snooping, while AES-256 is the option to use now. The password itself still sets the floor.
Should I pick ZIP or 7Z?
Judge by what the recipient can open. Every operating system handles ZIP without extra software, so it travels best. 7Z compresses further but needs a tool on the other end.