Compression
Two people pack the same clothes. One suitcase bulges; the other zips shut with room to spare. Computers pack data the same way.
Swipe or tap Next for the next section
Packing a Suitcase
A good packer doesn't leave anything behind — they just fold smarter. Socks go inside shoes, shirts get rolled, nothing is wasted. Same clothes, less space.
Or think about notes you scribble for yourself: "mtg w/ Sam @ 3 tmrw" says the same thing as "Meeting with Sam at three o'clock tomorrow" in half the letters.
Compression means storing the same information using fewer bits.
Fewer bits means files take up less storage and download faster. As you saw on Bits, Bytes, and Beyond, every photo, song, and video is really just a very long string of bits — and compression is how we keep those strings manageable.
A Simple Trick: Count the Repeats
Imagine a row of pixels in a black-and-white picture: ten white, four black, ten white. Instead of writing every pixel, you can write how many of each come in a row:
WWWWWWWWWWBBBBWWWWWWWWWW10W4B10W
24 characters became 8, and nothing was lost — you can rebuild the exact original from "10W4B10W". This trick is called run-length encoding. Try it:
Compressed
Counting each letter or digit as one byte, the way plain text is usually stored.
Compression Isn't Magic
Did you try "A normal word"? Run-length encoding made it bigger, because every single letter turned into "1" plus the letter. Compression only works when there's a pattern to take advantage of. Real compression tools use much cleverer pattern-spotting — like noticing a whole word or phrase that appears again and again and replacing it with a short code — but the same rule holds: no patterns, no savings.
Two Kinds of Compression
Lossless
Nothing is thrown away. You can always rebuild the exact original.
Examples: ZIP files, PNG images.
Use it for: text, documents, spreadsheets, apps — anything where one wrong letter or number matters.
Lossy
Throws away detail people probably won't notice. Much smaller files — but the lost detail is gone for good.
Examples: JPG photos, MP3 music, streamed video.
Use it for: photos, music, and video, where "nearly perfect" is perfectly fine.
How Lossy Compression Gets Away With It
A photo of a blue sky might contain thousands of very slightly different blues. Your eyes can't really tell them apart, so a JPG stores just a few blues instead. A song contains very quiet sounds hidden underneath louder ones; an MP3 simply leaves out what you wouldn't hear anyway.
The catch: once detail is thrown away, it can't be brought back. Save a JPG, open it, and save it again many times, and it slowly gets blurry and blocky — like a photocopy of a photocopy.
Lossless: smaller, and perfect. Lossy: much smaller, and "good enough." Which one to use depends on whether you can afford to lose anything.