If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

The need for compression

Modern computers can store increasingly large numbers of files, but file size still matters. The smaller our files are, the more files we can store.
We use compression algorithms to reduce the amount of space needed to represent a file.
An illustration of file compression, with a 50KB text document next to a 20 KB text document, with an arrow from the 50KB to the 20KB.
There are two types of compression: lossless and lossy.
Lossless compression algorithms reduce the size of files without losing any information in the file, which means that we can reconstruct the original data from the compressed file.
Lossy compression algorithms reduce the size of files by discarding the less important information in a file, which can significantly reduce file size but also affect file quality.
We'll first explore lossless compression techniques that work for text documents, simple images, and all binary data, and then explore lossy compression techniques for photos and audio.

Want to join the conversation?