How lossless compression makes a file smaller without changing it
Lossless compression replaces repeated or predictable data with a more compact representation. A decoder can reconstruct the original exactly because the necessary information remains encoded. A long run of identical values might be stored as one value plus a count, although real formats often use more sophisticated methods.
Go deeper
Store the pattern more efficiently
Lossless compression takes advantage of structure in data. Instead of storing every repeated element separately, it may describe repeated sequences, assign shorter codes to common values or use predictions.
A simple illustration is storing ten repeated letters as a letter and a count. The decoder follows the agreed rule to recover the original sequence.
No original information is deliberately discarded. Decompressing a correctly stored lossless file restores the same data that entered the compressor.
- Repetition creates opportunities for smaller representations.
- The format specifies how to reverse the encoding.
- Data with little exploitable structure may compress poorly.
A compressor cannot make every possible file smaller. Its own headers and instructions take space, and already compressed data often offers little additional redundancy to remove.