system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does file compression work?

Title basically says it all. I understand how photos and videos can trade quality for file size, but files like games or large folders can be shrunk into a .rar or .zip file, transferred, and pulled back out with no loss to functionality. How does that work? If nothing's being taken away how is space being saved?
gpt
Some files have patterns in them.  The compression tool looks through the file and finds the patterns.  Then it makes a new file with one copy of the patterns, followed by the rest of the file including a marker for "pattern 1 goes here" or "pattern 5 goes here".  Since the markers are smaller than the patterns, and some file have a very large number of certain patterns, the compressed format of the file can be much smaller.  Some files don't compress well, and the compression doesn't make them any smaller.

Above I've discussed lossless compression, where no information is destroyed.  There are other approaches used to compress sounds or images, that also lose some less significant information, but those operations are not lossless.