Ahmadreza Samadi / Home

Wait, That’s Tech? · Everyday technology

How ZIP files work: compression without losing data

A ZIP can bundle files, compress their contents, or do both. A smaller archive is useful only if extraction can reconstruct the original bytes exactly.

At a glance

ZIP is the container; DEFLATE is one compression method it can use. Files that are already compressed may barely shrink, and archive headers can even make the result larger. Compression does not provide confidentiality, and CRC-32 helps detect accidental corruption rather than proving authenticity.

How are ZIP and DEFLATE different?

ZIP stores individual file entries and a central directory that helps an extractor locate them. Entries can be stored without compression or use a supported compression method. DEFLATE is a common choice, but ZIP and DEFLATE are not interchangeable names.

How do repeated bytes become instructions?

In my animated example, the bytes ABCDABCD repeat a four-byte sequence. After the first ABCD, a compressor could represent the next part as “go back four bytes and copy four.” This illustrates an LZ77 length-distance match. It is not a promise about the exact output of a real compressor for such a short input.

Where does Huffman coding fit in DEFLATE?

DEFLATE can encode literals and match information using Huffman codes. A suitable code gives common symbols shorter representations. Fixed-code and uncompressed blocks also exist; a compressor chooses how to represent its data. Extraction decodes the instructions and rebuilds the bytes in order.

Why does a JPG or MP4 barely shrink?

Many photos and videos are already compressed. Another compression pass often finds little useful redundancy, and the archive's headers can even make the result larger. Bundling several files can still make a ZIP useful when it saves no space.

Is ZIP encryption?

Compression and encryption are separate. A ZIP is not confidential merely because it is compressed. Its CRC-32 check helps detect accidental corruption, but does not establish authenticity. In the film, I keep these jobs separate: package the files, represent their bytes compactly, then reconstruct them exactly.

Watch the original explainer

This article accompanies my published visual explainer. The social posts are in English.

Watch on Instagram · @ahmadreza_smdi · Watch on YouTube · Read the LinkedIn post

Sources