The ZIP (.zip) Format, Explained
iLoveConverter Team 4 min read
On this page
ZIP is the universal archive format. Windows has built-in support since XP, macOS since Jaguar, Linux since forever. Every programming language has a ZIP library. Email attachments are often ZIPped because attachments otherwise block or flatten directories. Despite 7Z and RAR offering better compression, ZIP’s ubiquity keeps it king — and ZIP64 removed the old 2 GB file size limit that was its biggest complaint.
Structure at a glance
A ZIP file is a sequence of:
- Local file headers — one per file, immediately followed by the compressed data. Each local header is 30 bytes plus variable-length filename and extra field.
- A Central directory — another set of headers listing every file with additional metadata (creation time, permissions, attributes, method used, CRC-32, compressed and uncompressed size).
- An End of Central Directory record (EOCD) — the 22-byte terminator that ties it all together.
Crucially, a file’s central directory entry and local header share the same compressed data. To list files, a parser only needs the EOCD and central directory — it can skip scanning the entire archive. This makes ZIP fast to open even when it contains thousands of files.
Compression methods
Each file in a ZIP can use a different compression method:
- Method 0: Store — no compression (for already-compressed files).
- Method 8: DEFLATE — zlib, the default and most common.
- Method 9: DEFLATE64 — 64-bit variant for large data.
- Method 12: BZIP2 — slightly better ratio than DEFLATE, slower.
- Method 14: LZMA — used by 7-Zip-created ZIPs.
- Method 93: Zstandard — newer, fast and efficient.
- Method 95: XZ — high ratio, slow.
A ZIP file is not limited to one compressor. You can mix and match — useful for leaving JPEGs as Store and text as DEFLATE.
ZIP64: fixing the limits
Original ZIP capped files at 2 GB and archives at 4 GB. ZIP64 (added in the AppNote 4.5 spec) extends these to exabytes. ZIP64 uses the central directory’s “extra field” to signal 64-bit sizes. A ZIP file is ZIP64 if any file exceeds 2 GB or the central directory offset exceeds 4 GB; older tools will reject these archives.
When to use ZIP
- Sending files to someone unknown — ZIP is the safest choice; they almost certainly can open it.
- Mixed media — ZIP lets you leave compressed files as Store and only compress the text.
- Incremental updating — you can append new files to a ZIP without rewriting the whole archive.
- Programmatic use — every language has built-in ZIP support; no extra libraries needed.
When not to use ZIP
- Maximum compression — use 7Z or RAR5.
- Recovery records — only RAR has that.
- Solid mode — ZIP has none, so repeated data across files is wasted.
Creating ZIP from command line
zip archive.zip file1.txt file2.png
zip -r archive.zip folder/
zip -9 archive.zip file1.txt # maximum DEFLATE effort
zip -j archive.zip folder/ # junk directory structure
unzip -l archive.zip # list contents
unzip -e archive.zip # extract with progress
Python example:
import zipfile
with zipfile.ZipFile("out.zip", "w", zipfile.ZIP_DEFLATED) as zf:
zf.write("file.txt")
Common problems
- CRC mismatch — corrupted file inside the archive. Re-download or test with
unzip -t. - ZIP bomb — a tiny ZIP that decompresses to terabytes. ZIP lets this happen because it reads sizes directly from the central directory. Always trust sources.
- Encoding issues — filenames in old ZIPs often use CP437 or OEM encoding; newer ZIPs use UTF-8 by setting flag bit 11. Tools may misinterpret if the flag is wrong.
- Encryption — standard ZIP encryption (PKWARE) is weak and crackable. AES (WinZip AES) is better but not universally supported.
FAQ
Why is ZIP so popular?
Because it works everywhere. No other format has the same combination of simplicity, ubiquity, and patent-free status. ZIP is the lowest common denominator for archives.
What’s the difference between a local header and a central directory entry?
The local header lives next to the data; the central directory entry lives at the end and has more metadata. A ZIP reader scans from the end using the EOCD, reads the central directory, and then jumps to the data — fast and scalable.
Can I create ZIPs with encryption?
Yes, but be aware of two encryption schemes. Standard PKWARE encryption is weak. WinZip AES-256 is strong but not all tools support it. If you need secure encryption, consider 7Z or a separate tool like age or GPG.
What is a ZIP bomb?
A specially crafted ZIP file where the compressed size is tiny but the uncompressed size is enormous (e.g., 42.zip compresses to 42 KB but unzips to 4.5 PB). This can crash services that auto-decompress uploads. Use size limits and safe parsers that validate before decompressing.
Try it yourself — free, right in your browser
Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.
Format deep-dives: ZIP (.zip) , 7Z (.7z) , RAR (.rar) , TAR (.tar)