You select a folder with 40 files, choose "compress," and get one smaller file. The computer did not squeeze the folder as a single lump. A ZIP file keeps every file as a separate entry, compresses each entry on its own, and adds an index at the end that lists all the entries.
This guide walks through that layout using the ZIP specification, explains two of its compression methods (DEFLATE and "stored"), and shows how to judge the result with the compression ratio calculator. You will also see why a folder of already-compressed files may barely shrink.
What is inside a ZIP file
The specification lays the archive out in a fixed order (section 4.3.6). Each file gets a local file header followed by its data. After the last file comes the central directory, which has one header per file. The archive ends with the end of central directory record, which holds the number of entries, the size of the directory and where it starts.
| Part | What it holds | Spec section |
|---|---|---|
| Local file header | Compression method, time, date, CRC-32, compressed size, uncompressed size, then the file name | 4.3.7 |
| File data | The entry's bytes, compressed or stored | 4.3.8 |
| Data descriptor | CRC-32 and both sizes, placed after the data; required when bit 3 of the general purpose flag is set | 4.3.9 |
| Central directory header | The same facts again, plus the position (offset) of the entry's local header | 4.3.12 |
| End of central directory record | Entry count, directory size, directory offset | 4.3.16 |
A CRC-32 is a check value computed from the file's data. The specification stores it in both the local and the central header for each entry. Files may sit in any order inside the archive (section 4.3.3), and the directory entries do not have to follow that order (section 4.4.1.3). The directory is therefore its own list, not a copy of the file order.
Each file is compressed on its own
Section 4.1.8 says each file "MAY be compressed, stored, encrypted or digitally signed independent of how other data files in the same ZIP file are archived." Three practical results follow.
First, the method is chosen per entry. One entry can use DEFLATE while the next is stored. Second, the central directory gives a program each entry's name, sizes and position, so the index and the data are separate pieces. Third, entries do not share repetition. DEFLATE replaces a repeated string with a pointer to an earlier copy, up to 32K bytes back (RFC 1951). Because every entry is its own compressed stream, a passage in the second file cannot point to a copy in the first.
Each entry also pays for its headers. Adding up the field sizes in sections 4.3.7, 4.3.12 and 4.3.16 gives 30 bytes for a local header, 46 bytes for a central header and 22 bytes for the end record, before file names.
Worked example. Example: a folder holds 1,000 files whose names average 20 bytes. Each name appears twice, once in each header, and we assume no extra fields, comments or data descriptors.
overhead = files × (30 + 46 + 2 × name length) + 22
overhead = 1,000 × (30 + 46 + 40) + 22 = 116,022 bytes
That is about 116 KB (1 KB = 1,000 bytes) before any file data. Real archives can add more, because the specification also allows extra fields and comments.
DEFLATE, stored and the other methods
Each entry has a two-byte compression method field (section 4.4.5). The specification adds that method 8 is "the method used by default by most ZIP compatible application programs" (section 4.1.3).
| Value | Name in the specification |
|---|---|
| 0 | Stored (no compression) |
| 8 | Deflated |
| 12 | BZIP2 |
| 14 | LZMA |
| 93 | Zstandard |
"Stored" means the file is copied into the archive uncompressed (section 4.1.7). DEFLATE combines two steps, described in RFC 1951: LZ77 replaces repeated strings with a pair of length and backward distance, and Huffman coding then writes the result in short codes. The article on how DEFLATE works follows both steps with an example.
DEFLATE has its own escape hatch. A compressed stream is made of blocks, and one block type holds its data uncompressed (specification section 5.5.2). RFC 1951 also notes that "no lossless compression algorithm can compress every possible input data set," and that the worst case for DEFLATE is 5 bytes of growth per 32K-byte block.
Why some folders barely shrink
DEFLATE saves space by finding repeats. A file already compressed by another method may have had many of its repeats removed, leaving little for DEFLATE to find. The ZIP specification does not discuss this case. It only says that compression is optional (section 4.1.3) and advises implementors "to experiment with their data to determine which of the available algorithms provides the best compression." The reasoning behind the effect is covered in why some files barely shrink.
To measure the result, compare the original total with the finished archive. The archive includes the headers above, so use its real size.
Worked example. Example: five files total 12,000,000 bytes, and the ZIP file is 4,500,000 bytes.
ratio = 12,000,000 ÷ 4,500,000 = 2.67 : 1
percent saved = (1 − 4,500,000 ÷ 12,000,000) × 100 = 62.5%
space saved = 12,000,000 − 4,500,000 = 7,500,000 bytes
Enter both sizes in the calculator to get the same three numbers. The article on compression ratio shows how to read them.
Common mistakes
- Expecting the same savings from every folder. The savings depend on what the files contain. Measure the original and archive sizes instead of assuming a percentage.
- Zipping media files to save space. Formats such as JPEG photos and MP3 music already compress their data, so the archive may be close to the original size. Compare the two sizes before keeping the extra step.
- Predicting the archive size by adding file sizes. Every entry adds two headers and two copies of its name. With thousands of tiny files, that overhead is noticeable.
- Reading "62.5% saved" and "2.67 : 1" as different results. They describe the same change. The ratio divides original by compressed, and the percentage is the share removed.
- Worrying that DEFLATE lowers quality. RFC 1951 defines a lossless format, so extracted data matches the original. Other methods in the list were not checked here.
FAQ
Does zipping a file lose quality?
Not with DEFLATE, the default method. RFC 1951 describes it as a lossless format, so unzipping returns the same data. This answer covers method 8 only.
What is the central directory for?
It lists every entry with its name, sizes and the offset of its local header. The end of central directory record is the last piece of the file, and it stores the offset where the directory starts.
Can a ZIP file hold folders?
Yes. A file name may include a relative path (section 4.4.17.1), and directories can appear as entries that carry no file data (section 4.3.8).
Are other file types secretly ZIP files?
Some are. An OpenDocument package must be a ZIP file, and its parts are either stored or compressed with DEFLATE. The package rules also say that a "mimetype" file, when present, shall be the first file and shall not be compressed.
Sources
- PKWARE, APPNOTE.TXT - .ZIP File Format Specification (Version 6.3.10). Accessed November 6, 2026.
- IETF, RFC 1951: DEFLATE Compressed Data Format Specification version 1.3. Accessed November 6, 2026.
- OASIS, Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 2: Packages. Accessed November 6, 2026.



