Introduction
ZIP bundles files and folders into one archive and compresses each file separately. Phil Katz created it for PKWARE’s PKZIP in 1989, and PKWARE still publishes the specification, APPNOTE.TXT. Windows and macOS open ZIP files with no extra software, which makes it the most widely used archive format.
Many formats are ZIP files with another extension and a set layout inside: Word documents, Excel workbooks, PowerPoint presentations, EPUB ebooks, Java archives, Android packages and 3MF print models. Any ZIP tool can open them to show the files inside.
Structure
A ZIP file has two lists of its contents. Each file is stored with a local file header in front of its data, and the central directory near the end lists every file again with the offset of its local header. The end of central directory record comes last, so a reader starts at the end of the file, finds that record, and reads the directory from there. All numbers are little-endian.
0Local file headerPK 03 04, method, time, CRC-32, sizes, name30 bytes + name + extra…File data stored or compressedvaries…More files a header and data for eachrepeated…Central directory onePK 01 02entry per file46 bytes + name + extra + comment each…End of central directoryPK 05 06, entry count, directory size and offset, comment22 bytes + comment
The usual compression method is 8, DEFLATE; method 0 stores a file as it is, and the specification also defines others such as bzip2, LZMA and Zstandard. Archives over 4 GiB, or with more than 65,535 files, use the ZIP64 extensions, which add 64-bit sizes and offsets.
Links
Software
- File Explorer, built into Windows
- Archive Utility, built into macOS
- 7-Zip (Windows)
- WinRAR (Windows)
- PeaZip (Windows, macOS, Linux)
- The Unarchiver (macOS)
- Info-ZIP
zipandunzip(macOS, Linux, Windows)
Developers
- libzip, C library that reads, writes and changes ZIP archives
- zipfile, Python standard library
- archive/zip, Go standard library
Reference
- APPNOTE.TXT, the ZIP file format specification from PKWARE