Can you help me understand the different file compression formats? It seems like there are a ton out there (zip, gzip, bzip1, tar, rar, 7z, etc.), but what are the differences between them, and which one should I use?
This is a good question, as it seems like every other file you download nowadays is in a different compression format, especially if you use multiple operating systems. First, we'll provide a very brief overview of how these compression formats work and the features that matter. Then, we'll note a few of the most popular formats and how they compare to one another.
How Archives Work
Archive formats are most often used for two reasons: the ability to combine multiple files into one (for simple uploading or downloading), and compressing them (so they take up less space). Many formats also provide other features, like encryption, but we won't go into that today.
While most formats will archive and compress a group of files for you, a few formats are only designed to do one or the other. Tar, for example, only archives files, while gzip and bzip only compress files (and aren't able to combine multiple files into one). This is why you often see formats like tar.gz, which combine both of those formats into one for archiving multiple files and compressing them.
In general, unless you have special needs (like encryption), the three features you really want to look for in an archive format are compression ability (how much space you can save), compression time (how fast a given archive can be compressed or decompressed), and the software you'll need to use the format.
How to Pick the Right Archive Format for Your Needs
If you're archiving files for other people, I'd recommend using plain old zip. Unfortunately, most other formats (at least for Windows and Mac users) are going to require the other person download and install extra software, and no one wants to do that. If you absolutely have to, you can use something else, but the more difficult you make it for other people (especially non-tech-savvy people), the more they're going to wonder if what you're sending them is worth their while.
That said, if you're archiving for your own purposes—say, moving large files or groups of files between computers—you have quite a few options. There are way too many archive formats to go through here, so we'll list some of our favorites and their pros and cons.
- Zip: It won't compress your files down a ton, but it's super fast and you don't need to install any extra software. Great for Windows and Mac users.
- Tar.gz: Similar to zip, tar.gz files are pretty darn fast. It's the most universally available option for Linux users, and also compresses files to a slightly smaller size than zip. Great for Linux usess.
- Tar.bzip2: Another great option for Linux users; tar.bzip2 is a bit slower than tar.gz, but will compress files to a smaller size.
- 7z: The archive format made popular by our favorite compression tool, 7-Zip. It's pretty slow, but it compresses files like nobody's business. This is the best format to use if you need a really, really small file. 7-Zip is only available for Windows, but you can get a command-line tool for Mac OS X and Linux, too. 7z is one of the only compression formats that can split files up into multiple archives and put them back together, too. This may seem counterintuitive, but it's useful if you're trying to send many large files over something like email, which limits the size of the files you send
- RAR: This format is comparable to 7z. 7z usually has better compression, with a few notable exceptions like mp3s in which case RAR compresses to smaller sizes. However, the only software that creates RAR files (WinRAR) is shareware, and Windows-only. You can uncompress RAR files on Mac and Linux, but not create them. RAR can also split up compressed archives into multiple parts.
So which should you use? I personally use 7z unless I'm in some sort of rush, because it compresses so well. I don't like RAR because of its price or Windows-only nature, and I'm primarily a Mac and Linux user. As always, the best format is whatever best fits your need in any given situation. If you're a Windows user and you're compressing files for other Windows machines, RAR and 7z are both good bets. Mac and Linux users will want to stick with tar.gz, tar.bz2 or 7z (though Mac users will need a program like GUI Tar to create these formats, unless they want to delve into the command line).
P.S. This is a pretty basic summary, and a lot of this is opinion (and some people have some pretty strong opinions that may disagree with my own!). So if you have your own favorite archive format, let us know what it is and why you love it in the comments.