TAR libraries
Open-source libraries that read and write TAR archives. Many languages have TAR in the standard library (Go, Python, .NET, PHP’s Phar extension). TAR libraries handle only the archive layer: for .tar.gz you wrap the file stream in a gzip stream (often from the standard library too), and for .tar.xz or .tar.zst you may need an extra package.
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| C/C++ | libarchive | yes | yes | every tar variant and compressor, the engine of bsdtar |
| C/C++ | microtar | yes | yes | 2 files, MIT, basic headers only, unmaintained |
| C# | System.Formats.Tar | yes | yes | built into .NET 7+, pax/GNU/ustar/v7 |
| C# | SharpCompress | yes | yes | also .tar.gz, .tar.bz2, .tar.xz, .tar.zst (read) |
| Java | Apache Commons Compress | yes | yes | streams and random access, pax and GNU |
| Go | archive/tar | yes | yes | standard library, pax/GNU/ustar |
| Python | tarfile | yes | yes | standard library, gzip/bz2/xz/zstd built in |
| Ruby | minitar | yes | yes | pure Ruby, ustar and GNU long names, no pax |
| Rust | tar | yes | yes | streaming, pure Rust, used by cargo |
| PHP | PharData | yes | yes | bundled with PHP, also gzip/bzip2 |
| PHP | php-archive | yes | yes | pure PHP, streaming, low memory |
By language#
- TAR libraries for C/C++ Open-source C and C++ libraries to read and write TAR archives: libarchive for every tar variant and compressor, microtar for tiny embedded use. Code examples.
- TAR libraries for C# Open-source .NET libraries to read and write TAR in C#: System.Formats.Tar built into .NET 7+, and SharpCompress for .tar.gz, .tar.bz2, .tar.xz and .tar.zst.
- TAR libraries for Java Open-source Java library to read and write TAR, .tar.gz, .tar.xz and .tar.zst archives: Apache Commons Compress, with code examples.
- TAR libraries for Go Read and write TAR, .tar.gz, .tar.xz and .tar.zst archives in Go with the standard archive/tar package. Code examples for listing, extracting and creating.
- TAR libraries for Python Read and write TAR, .tar.gz, .tar.bz2, .tar.xz and .tar.zst archives in Python with the standard library tarfile module. Code examples and safe extraction.
- TAR libraries for Ruby Open-source Ruby library to read and write TAR and .tar.gz archives: minitar, pure Ruby, with code examples. Also notes on Gem::Package::TarReader.
- TAR libraries for Rust Read and write TAR, .tar.gz, .tar.xz and .tar.zst archives in Rust with the tar crate, combined with flate2, xz2 or zstd. Code examples.
- TAR libraries for PHP Read and write TAR, .tar.gz and .tar.bz2 archives in PHP with the built-in PharData class or the pure-PHP php-archive library. Comparison and code examples.