{"id":250,"date":"2026-11-26T09:00:00","date_gmt":"2026-11-26T14:00:00","guid":{"rendered":"https:\/\/quentinpidcock.com\/content\/?p=250"},"modified":"2026-11-26T09:00:00","modified_gmt":"2026-11-26T14:00:00","slug":"how-a-zip-file-squeezes-a-document-without-losing-a-single-word","status":"publish","type":"post","link":"https:\/\/quentinpidcock.com\/content\/how-a-zip-file-squeezes-a-document-without-losing-a-single-word\/","title":{"rendered":"How a Zip File Squeezes a Document Without Losing a Single Word"},"content":{"rendered":"<p>Take a long document, zip it, and the file might come out half its original size \u2014 sometimes much smaller. Unzip it, and you get back the original document exactly, every word and every space, nothing approximated and nothing thrown away. That sounds like a magic trick, because squeezing something down usually means removing part of it. File compression does something cleverer. It does not remove information. It removes waste.<\/p>\n<h2>Files Are Full of Repetition<\/h2>\n<p>The key insight is that ordinary files are padded with redundancy. English text uses the same words constantly \u2014 the, and, of \u2014 and the same letters in the same combinations. A file stored the plain way spends the same amount of space on the thousandth &#8220;the&#8221; as it did on the first one, as if each were a surprise. Images repeat colors across whole regions. Documents repeat formatting, spacing, and structure. Plain storage pays full price for every repetition. Compression is the business of noticing the repetition and refusing to pay for it twice.<\/p>\n<h2>Trick One: Shorter Codes for Common Things<\/h2>\n<p>The first trick is to rewrite the file in a kind of shorthand. Instead of giving every symbol the same fixed amount of space, you give the common ones very short codes and let the rare ones be longer. The letter &#8220;e&#8221; might get a tiny code; an unusual symbol gets a long one. Since the common symbols vastly outnumber the rare ones, the total comes out smaller \u2014 the same principle behind Morse code, where the most common letter in English is a single dot. Nothing is lost in this trick, because the shorthand is exact: a table built for that particular file says precisely which code stands for which symbol, and the decoder follows it back perfectly.<\/p>\n<h2>Trick Two: Pointing Instead of Repeating<\/h2>\n<p>The second trick is even more powerful. When the compressor finds a stretch of data it has already seen \u2014 a word, a phrase, a run of identical values \u2014 it does not write the stretch out again. It writes a small pointer instead: in effect, &#8220;same as back there, this long.&#8221; A document that uses the same phrase two hundred times stores it once and points at it a hundred and ninety-nine times. This is why text compresses so well and why already-compressed files barely shrink at all: a file that has had its repetition squeezed out has nothing left for the second pass to find. It is also why a photograph and a page of text behave so differently \u2014 text is repetition all the way down.<\/p>\n<p>Real compression formats combine both tricks: first the pointing pass collapses the repeats, then the shorthand pass squeezes what remains. Zip is the household name, but the same two ideas sit underneath nearly every lossless format in use.<\/p>\n<h2>Lossless Versus Lossy \u2014 and Why the Difference Matters<\/h2>\n<p>Everything above is lossless compression: the original comes back bit for bit, which is the only acceptable behavior for documents, programs, and data. There is a second family, lossy compression, used for photos, music, and video, which does throw information away \u2014 the details human eyes and ears are least likely to miss \u2014 and gets far smaller files in exchange. That trade is fine for a photograph. It would be unacceptable for a contract, a spreadsheet, or a program, where changing even one character changes the meaning. Knowing which family a format belongs to tells you whether &#8220;compressed&#8221; means &#8220;smaller and identical&#8221; or &#8220;smaller and close enough.&#8221;<\/p>\n<h2>Why This Matters to You<\/h2>\n<p>Compression is one of those invisible technologies holding up everything else. Backups fit because of it. Downloads are fast because of it. The storage you do not have to buy is bought by it. And the principle is worth keeping even outside of computers: most information people drown in is repetition wearing a new coat. The zip file&#8217;s whole trick is refusing to store the same thing twice \u2014 a discipline that works on more than data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Take a long document, zip it, and the file might come out half its original size \u2014 sometimes much smaller. Unzip it, and you get back the original document exactly, every word and every space, nothing approximated and nothing thrown away. That sounds like a magic trick, because squeezing something down usually means removing part [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-articles"],"_links":{"self":[{"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":1,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"predecessor-version":[{"id":280,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/posts\/250\/revisions\/280"}],"wp:attachment":[{"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quentinpidcock.com\/content\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}