7z libraries
Open-source libraries that read and write 7z archives. Fewer languages have native 7z support than ZIP: some libraries are pure implementations of the format, others wrap the 7-Zip DLL / shared library or the 7z command-line program. Check what you need before you choose: writing, encryption (AES-256), solid archives and the compression methods in the files you get (LZMA2, BCJ2, PPMd, Zstandard).
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| C/C++ | libarchive | yes | yes | one API for many archive formats; no encryption |
| C/C++ | LZMA SDK | yes | no (in C) | public domain reference decoder by the author of 7-Zip |
| C/C++ | bit7z | yes | yes | C++ wrapper of the 7-Zip DLL / shared library; encryption, all methods |
| C# | SharpCompress | yes | yes | pure managed; writes non-solid LZMA/LZMA2 archives |
| C# | SevenZipExtractor | yes | no | wraps 7z.dll, Windows only |
| Java | Apache Commons Compress | yes | yes | pure Java, reads encrypted archives |
| Go | sevenzip | yes | no | pure Go, archive/zip-like API, fs.FS |
| Python | py7zr | yes | yes | pure Python, encryption, zipfile-like API |
| Python | libarchive-c | yes | yes | ctypes binding to libarchive |
| Ruby | seven-zip | yes | yes | native extension bundling 7-Zip code |
| Ruby | ffi-libarchive | yes | yes | FFI binding to libarchive |
| Rust | sevenz-rust2 | yes | yes | pure Rust, AES-256, solid and non-solid |
| PHP | Archive7z | yes | yes | wrapper of the 7-Zip command-line program |
By language#
- 7z libraries for C/C++ Open-source C/C++ libraries to read and write 7z archives: libarchive, the LZMA SDK and bit7z. Comparison and code examples.
- 7z libraries for C# Open-source C# and .NET libraries to read and write 7z archives: SharpCompress and SevenZipExtractor. Comparison and code examples.
- 7z libraries for Java Open-source Java library to read and write 7z archives: Apache Commons Compress (SevenZFile, SevenZOutputFile). Code examples.
- 7z libraries for Go Open-source Go library to read 7z archives: github.com/bodgit/sevenzip, a pure-Go reader modeled on archive/zip. Code examples.
- 7z libraries for Python Open-source Python libraries to read and write 7z archives: py7zr and libarchive-c. Comparison and code examples.
- 7z libraries for Ruby Open-source Ruby libraries to read and write 7z archives: the seven-zip gem (SevenZipRuby) and ffi-libarchive. Comparison and code examples.
- 7z libraries for Rust Open-source Rust library to read and write 7z archives: sevenz-rust2, a pure-Rust 7z compressor and decompressor with AES-256. Code examples.
- 7z libraries for PHP Open-source PHP library to read and write 7z archives: Archive7z, a wrapper of the 7-Zip command-line program. Code examples.