What ZIP Compression Actually Does, and When It Does Nothing

A ZIP of photos is the same size as the photos. A ZIP of spreadsheets is a tenth of the size. The difference is not the ZIP, it is what was already inside the files.

Two jobs that share one file extension

A ZIP does two separate things, and people conflate them. One is bundling: putting many files into one so they travel together and keep their folder structure. The other is compressing: making the bytes smaller. Bundling always works. Compressing only works on some files, and the file extension gives you no hint which.

The compression inside nearly every ZIP is DEFLATE, specified in RFC 1951. It works by finding runs of bytes that appeared earlier and replacing them with a short reference back, then encoding the result so that common symbols take fewer bits. Both tricks depend on repetition. A file with a lot of it shrinks dramatically. A file with none does not shrink at all.

What shrinks

Text, by a lot. English prose has a small alphabet and repeats words constantly, and a CSV repeats whole columns of near-identical values. A 10 MB CSV routinely becomes 1 MB. Log files, source code, HTML and JSON all behave the same way, and the split CSV tool is worth running before zipping if a single file is too large to open at the other end anyway.

Uncompressed images, meaning BMP and uncompressed TIFF, shrink well because large areas of a picture repeat. WAV audio shrinks a little, since the sample values drift rather than repeat exactly. Older Office documents in the .doc and .xls formats shrink substantially.

Anything you generate in bulk from a template shrinks absurdly well, because the template is the same every time. A thousand invoices as plain HTML can zip to a few percent of their total.

What does not

JPEG, PNG, WebP, HEIC. MP3, M4A, AAC, OGG. MP4, WebM, MOV. Modern Office files in .docx and .xlsx. PDFs with images in them. Every one of these is already compressed internally, often with DEFLATE itself. The repetition DEFLATE looks for has already been removed, and a second pass finds nothing. Zipping a folder of photos produces a file within a percent or two of the folder's size, and occasionally slightly larger, because the ZIP adds its own headers.

This is the source of most "the ZIP did not help" complaints. The ZIP worked exactly as designed; there was nothing left to take. To make a photo smaller you have to re-encode the photo, which is what the image compressor does, and to make a PDF smaller you downsample the images inside it, which is what the PDF compressor does. Both lose a little quality; a ZIP loses none and saves none.

So why zip the photos anyway

Because bundling is still useful. One attachment instead of forty. The folder structure preserved. A single checksum for the whole set. Email clients that cap the number of attachments but not the size. A recipient who can double-click one file rather than save forty.

The create ZIP tool does real DEFLATE compression in the browser using the compression engine the browser itself ships, so files that can shrink do, and files that cannot are stored with the overhead kept small. Nothing is uploaded, which for a bundle of client files is the point.

Levels, and why level 9 is rarely worth it

DEFLATE has a compression level from 1 to 9 that trades time for size. The difference between level 6, the usual default, and level 9 is typically one or two percent on text and nothing at all on already-compressed files, for several times the processing time. Level 9 is for an archive that will be downloaded a million times. For a file going to one person, the default is right.

There are newer algorithms that beat DEFLATE, such as the ones behind .7z and .zst files, by a meaningful margin on large text. The reason ZIP persists is that every operating system opens it without installing anything, and the recipient's convenience is usually worth more than ten percent of the size.

Encryption is a different question

The password option in older ZIP tools uses an encryption scheme that was broken decades ago and should be considered decorative. Newer tools offer AES inside a ZIP, which is sound, but the recipient needs a tool that supports it. If the contents are sensitive, encrypting them properly before bundling is more reliable than relying on the archive, and keeps the choice of tool with you.

Questions people ask

Why is my ZIP file the same size as the original files?

Because the files were already compressed. JPEG, PNG, MP3, MP4, PDF with images and modern Office formats all have compression built in, and DEFLATE finds nothing left to remove. The ZIP has still bundled them into one file, which is often the actual goal.

Which files compress well in a ZIP?

Text of any kind: CSV, JSON, HTML, source code, logs, plain-text documents. Uncompressed images such as BMP. Older .doc and .xls files. Anything generated from a template. These routinely shrink by 70 to 95 percent.

How do I make a folder of photos smaller to send?

Re-encode the photos rather than zipping them. Lowering the JPEG quality or the pixel dimensions is what reduces a photo's size; a ZIP cannot. Then bundle the smaller photos in a ZIP so they travel as one attachment.

Is a ZIP password secure?

The traditional ZIP password scheme is not; it was broken long ago. AES-encrypted ZIPs are secure but need a compatible tool at both ends. For anything sensitive, encrypt the contents with a proper tool first and treat the ZIP as packaging.

Does compression level 9 make a big difference?

Rarely. On text it typically saves another one to two percent over the default level for several times the processing time, and on already-compressed files it saves nothing. The default level is the right choice for almost everything.

Read next

All articles