# How compression works

Source: https://listme.name/learn/topic/compression

Run-length encoding, Huffman coding, LZ77 and DEFLATE explained one idea at a time, then how to choose between gzip, xz, Zstandard and Brotli for a real job.

- [How file compression works](https://listme.name/learn/how-file-compression-works.md): See how lossless compression shrinks files with run-length encoding, Huffman coding and LZ77 pointers, and why ZIP, gzip and PNG all rely on DEFLATE.
- [Huffman coding explained: shorter codes for common symbols](https://listme.name/learn/huffman-coding-explained.md): Learn how Huffman coding builds a tree from symbol counts, gives frequent letters short codes, and decodes without separators, with a worked example.
- [LZ77 and DEFLATE: how ZIP, gzip and PNG compress](https://listme.name/learn/lz77-and-deflate-how-zip-works.md): Learn how LZ77 pointers, DEFLATE blocks and Huffman codes work together, why a pointer can overlap its own output, and how ZIP differs from tar.gz.
- [Lossless vs lossy compression: what gets thrown away](https://listme.name/learn/lossless-vs-lossy-compression.md): Lossless compression gives back every byte. Lossy compression discards detail on purpose. See what JPEG and MP3 drop, why re-saving hurts, and what to keep.
- [Choosing a compression algorithm: gzip, xz, Zstandard, Brotli](https://listme.name/learn/choosing-a-compression-algorithm.md): Compare gzip, bzip2, xz, Zstandard and Brotli by size, speed and memory, then pick one for web assets, backups, archives or files other people must open.
