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. A ZIP file dropped on any page of this site opens in the explorer, which shows these records field by field.
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 rest of the format is described on these pages:
- Archive layout – the order of the records, their signatures and how a reader finds them
- Local file header – the header in front of each member’s data
- Data descriptor – sizes and CRC-32 written after the data when they were not known
- Central directory – the index of members, and the digital signature
- End of central directory – the last record, and how to find it
- ZIP64 – 64-bit sizes, counts and offsets, and when each field moves
- Shared fields – version numbers, flags, MS-DOS times, CRC-32 and attributes
- Compression methods – the method numbers and how each is framed
- Extra fields – the registry of IDs and the common blocks byte by byte
- File names – paths, folders, encodings and comments
- Encryption – traditional PKWARE, WinZip AES and strong encryption
- Split archives – split and spanned archives, disk numbers and naming
- Reading and writing – a step-by-step reader and writer, and the pitfalls
- Versions – the history of the specification
Not described
Known, not yet covered
- Reference: the statements about writers that APPNOTE does not make now cite the
source they were read from (CPython v3.14.0, libzip v1.12.1, OpenJDK jdk-21-ga, 7-Zip and libarchive for
PPMd restoration, AOSP apksig for
0xD935), each fetched raw on 2026-11-19 and not run. One number was not read: the default of apksig’sLIBRARY_PAGE_ALIGNMENT_BYTES, which sets the alignment of.sofiles, so the Android alignment section does not give it. Whether Android’s ownzipaligntool writes the0xD935block was not checked: its source files that were read do not mention it. - Viewer: WavPack (method 97) and CMPSC (method 16) members decode, but have only been tested on data the site built, since no real files of either were available.
- Viewer: encrypted members are shown with all their headers, but not decrypted: there is no way to enter a password yet.
- Viewer: when the archive is opened, members are decoded and checked against the directory’s size and CRC-32 until 64 MiB of contents have been checked. A decoded member past that is checked when it is opened; a failure then joins the Problems list, marked as found after opening, and the Overview’s “Data check” row does not change. A stored member past the 64 MiB is checked against its CRC-32 when it has been read through to its last byte (opened and parsed whole, or its hex view paged to the end), in pieces of 1 MiB with only the running checksum kept; a failure then joins the Problems list in the same way. A stored member that is only ever read in windows is not read in full to check it, and is not checked.
- Viewer: a Deflate, Deflate64, BZip2, LZMA, XZ, PPMd or Zstandard member of any size is read in windows. A member of another method (Shrink, Reduce, Implode, WavPack, CMPSC) is decoded whole, so one that decompresses to more than 256 MB is not opened. A PPMd model over 16 MiB and a Zstandard window over 16 MiB have no checkpoints: a read behind the place already decoded decodes again from the start, which is slower but reaches all the data. A Zstandard frame that names a dictionary is decoded whole, and the frame’s own content checksum is not computed (the ZIP CRC-32 covers the data).
- Viewer: a Zstandard member of more than 64 MiB keeps its frame’s own window, up to
128 MiB (
zstd --long=27, which is also the zstd tool’s own default limit for a decoder); memory is then up to 192 MiB for the window. A frame that declares a window above 128 MiB (--long=28and more) is read as long as no match reaches back further than 128 MiB; one that does is reported, not guessed. Fixed 2026-11-14 (the output of 40 MiB of random data twice with--long=27, and 33 MiB twice with--long=26, equalszstd -dc). - Viewer: an XZ member (method 95) read in windows reports a damaged stream header, index or footer, stream padding and trailing bytes (the same checks as the .xz viewer) once its data has been read to the end, the way the directory’s CRC-32 is reported; the data before is readable. A member that is only read in part does not meet the report. Fixed 2026-11-14.
- Viewer: an XZ member with several blocks that is cut short shows the decoded bytes
of the block it was cut in, as far as
xz -dcgets (the count is equal), then the error “Block N: the compressed data ends in the middle of a symbol”. Fixed 2026-11-14.
Unknown
- Reference and viewer: whether mainframe writers of CMPSC members (method 16) follow APPNOTE’s little-endian default (4.3.3, 4.4.1.1) for the dictionary length: no archive made with method 16 was available to check. The explorer reads it little-endian first, and says in the viewer when it falls back to big-endian (its own heuristic).
- Reference: the bit layout of a CMPSC expansion dictionary entry is described on the
compression methods page from the Hercules
emulator’s source, which was written to IBM’s ESA/390 Data Compression (SA22-7208-01). That
manual, which APPNOTE cites, was not found public, and IBM’s public Principles of Operation
(SA22-7832-10) describes the instruction and the dictionary sizes but sends the reader to the
SA22-7208-01 for the entry format. Whether a compressed dictionary stored with Deflate (flag
0x40) counts its length in compressed bytes is the explorer’s reading, as APPNOTE 5.17 says only “length of the expansion dictionary”. - Viewer: the device numbers in the z/OS
fldata_textra field, which IBM does not publish beside the structure. Shown as numbers.
Links
Software
- File Explorer – Windows opens ZIP files like folders and makes them with “Compressed (zipped) folder” (Windows)
- Archive Utility – the Mac’s built-in extractor; Finder’s Compress makes ZIP files (macOS)
- 7-Zip – free archiver that opens and makes ZIP files (Windows)
- WinRAR – archiver that opens and makes ZIP files (Windows)
- PeaZip – free archiver for many formats (Windows, macOS, Linux)
- The Unarchiver – free extractor for many formats (macOS)
- Info-ZIP – the
zipandunzipcommands (macOS, Linux, Windows)
Developers
- libzip – reads, writes and changes ZIP archives (C)
- zipfile – standard library module (Python)
- archive/zip – standard library package (Go)
Reference
- APPNOTE.TXT – the ZIP file format specification from PKWARE
- AES encryption information – WinZip’s description of AE-1 and AE-2
- extrafld.txt – Info-ZIP’s notes on extra fields, in libzip’s copy