7-Zip (p7zip)
Creates and extracts 7z, with the best general-purpose compression ratio available.
What it does
7z implements the 7z format — LZMA/LZMA2 compression, solid archives, AES-256 encryption including encrypted headers — and reads most other formats too.
7z a archive.7z folder/ # create
7z a -mx=9 -mhe=on -p archive.7z f/ # max compression, encrypted headers, password
7z x archive.7z # extract preserving paths
7z l archive.7z # list contents
7z t archive.7z # test integrityNotes
-mhe=on encrypts the file list as well as the contents; without it an encrypted archive still reveals every filename inside. -mx=9 is slow and memory-hungry, but the ratio difference on source code and text is substantial.
The p7zip formula is the POSIX port; Homebrew also carries sevenzip, the official upstream build.
Alternative to
| Alternative | Type | Trade-off |
|---|---|---|
| sevenzip | Open source | The official upstream 7-Zip build, also in Homebrew, and better maintained |
| Keka | Open source | The same formats with a GUI |
| zstd | Open source | Much faster for everyday compression, if the recipient has it |
| tar plus xz | Built in | Universally available on Unix |
Install
brew install p7zip