Convert TAR.BZ to TAR.GZ Online (Bzip2 Tarball to a Gzip One)
The compression math behind why gzip became the near-universal default, and what a parallel gzip implementation changes about the speed side of that trade.
- Add a file Choose or drop it here
- Pick the format Change it whenever needed
- Download the result After conversion completes
Two Compressors, One Identical Tar Stream Between Them
A .tar.bz file is a tar stream compressed with bzip2, using a shortened compressor suffix for the same content most tools spell out as ".tar.bz2." A .tar.gz file starts from that identical kind of tar stream — the same 512-byte-block bundling format tracing back to Unix's Seventh Edition in 1979 — but compresses it with gzip instead. Converting between the two touches only that outer compression layer: bzip2 decompression exposes the plain tar bytes, and gzip then compresses that same stream from scratch.
Gzip's own file format is documented in RFC 1952, a specification that spells out its structure down to the byte: every gzip stream begins with two fixed magic bytes (0x1F, 0x8B), followed by a compression-method byte and a flags byte controlling which optional fields — an embedded original filename, a comment, a header checksum — are present. At the very end, gzip stores a CRC-32 checksum of the uncompressed data and its size. That trailing size field is only 32 bits wide, meaning it records the original file's length modulo 2^32 — a real, documented limitation that makes gzip's own reported "uncompressed size" for anything over 4 GB simply wrong, wrapped back around from zero, unless the data is actually decompressed to measure it directly.
Why Bzip2's Bigger Blocks Don't Automatically Mean a Better Real-World Choice
Bzip2 compresses in blocks of up to 900 KB using a Burrows-Wheeler transform, giving it a wider view of repeated patterns than gzip's DEFLATE algorithm, which works within a much smaller 32 KB sliding window using LZ77-style back-references. That difference in scope is exactly why bzip2 usually produces a smaller archive on text-heavy content — but scope isn't free: bzip2 compression commonly runs four to twelve times slower than gzip on equivalent data, a gap wide enough to matter on anything run repeatedly, like an automated build or backup job.
Gzip's own speed advantage can be pushed further still with pigz, a parallel reimplementation written by Mark Adler — one of gzip's own original authors — which splits input into 128 KB chunks and compresses them across multiple CPU cores simultaneously, producing standard gzip-compatible output any ordinary gzip or tar -z command can read normally. Documented benchmarks show pigz compressing a several-gigabyte tar file in a small fraction of the time single-threaded gzip needs on the same multi-core hardware, though pigz's decompression isn't actually parallelized the same way — only its compression side benefits from multiple cores directly.
What Switching From Bzip2 to Gzip Compression Gains and Costs
- Gain — meaningfully faster compression and decompression: gzip's smaller sliding window and simpler algorithm run several times faster than bzip2's block-sorting approach on the same data.
- Gain — access to parallel tooling like pigz: for very large archives, pigz can spread gzip compression across all available CPU cores, cutting wall-clock time well beyond what single-threaded bzip2 or gzip can offer.
- Gain — the format most build systems and package tools default to: gzip remains the more broadly assumed default across general-purpose scripting and package management.
- Lose — some compression ratio: the resulting .tar.gz is typically somewhat larger than the .tar.bz it replaced, since gzip's narrower window can't match bzip2's wider-context matching on repetitive text.
- Lose — bzip2's fixed, modest compression memory footprint: bzip2 needs roughly 7.6 MB to compress at its default 900 KB block size regardless of file size, a much smaller and more predictable ceiling than some alternative compressors demand.
- Unchanged — everything the tar stream itself recorded: file names, permissions, and timestamps come out identical either way, since only the compression method wrapped around that stream changes.
Where Gzip's Format Details Actually Show Up in Practice
Both bzip2 and gzip ship by default on essentially every Linux distribution and macOS, and Windows has included a tar.exe capable of both since Windows 10 build 17063, using the -j flag for bzip2 and -z for gzip. The RFC 1952 header format's optional FNAME field, when set, lets a gzip stream carry its own original filename independent of whatever the file on disk is actually called — a detail some archiving tools use to recover a sensible name if a .gz file gets renamed generically, though tar-wrapped archives typically rely on the outer .tar.gz filename instead of that embedded field.
Pigz isn't installed by default on most systems the way gzip and bzip2 are, but it's packaged in the standard repositories of every major Linux distribution and available through Homebrew on macOS, and its output remains fully readable by plain gzip or tar's own -z flag, since pigz produces standard-compliant gzip data rather than a variant format of its own.
RFC 1952 also defines an optional FHCRC flag, which, when set, stores a 16-bit checksum of the header itself immediately before the compressed data begins — a smaller, separate check from the full 32-bit CRC-32 covering the actual decompressed content at the end of the stream. Few modern tools bother setting FHCRC in practice, since the trailing full CRC-32 already catches header or data corruption on decompression, but its presence in the specification is a reminder that gzip's format was built with more integrity-checking machinery than most users ever interact with directly.
Real Complaints Reported Around This Specific Compressor Swap
A recurring theme in CI pipeline discussions involves teams noticing that bzip2-compressed build artifacts measurably slow down every single automated build, since compression runs on every build rather than once — the documented fix in most of these threads is switching build output to gzip, sometimes specifically to pigz for large artifacts, accepting a modestly larger file in exchange for meaningfully shorter pipeline time.
A second reported issue involves a script relying on gzip's own ISIZE field to report a source file's uncompressed size without decompressing it, and getting a wrong, wrapped-around number for anything over 4 GB — the field is only 32 bits and stores the size modulo 2^32, a documented limitation of the gzip format itself rather than a bug in any particular tool, and the reliable workaround reported in these threads is piping the decompression output through a byte counter instead of trusting the header value.
A third pattern involves someone expecting pigz to speed up decompression the way it clearly speeds up compression, then finding decompression times barely improve — pigz's own documentation is explicit that its decompression isn't meaningfully parallelized the same way compression is, since DEFLATE's decompression is inherently more sequential, and the speed gain from pigz is real but specifically one-directional.
A fourth documented pattern involves a data-processing pipeline built around gzip specifically because a downstream tool inspects the FNAME field inside the gzip header to recover the original filename after the outer file got renamed during transfer — switching that same pipeline's source data from a .tar.bz to a .tar.gz preserves that specific capability, whereas the same workaround has no equivalent inside a bzip2 stream, which carries no comparable embedded-filename field at all.
Bzip2 and Gzip's Format Details Side by Side
| Feature | TAR.BZ (bzip2) | TAR.GZ (gzip) |
|---|---|---|
| Governing specification | No single formal RFC | RFC 1952 |
| Compression window | 900 KB blocks | 32 KB sliding window |
| Uncompressed-size field limit | Not applicable, no such field | 32-bit, wraps past 4 GB |
| Parallel compression tool | pbzip2 (block-independent) | pigz (chunk-independent) |
| Typical compression speed | 4-12x slower than gzip | Baseline, considerably faster |
| Typical ratio vs. the other | Usually smaller output | Usually larger, but faster to produce |
Common Questions About Switching Bzip2 Tarballs to Gzip
Is a .tar.bz file the same as a .tar.bz2 file for this conversion?
Yes, in virtually every real case — both hold bzip2-compressed tar data, so the conversion to .tar.gz works identically regardless of which spelling the source file uses.
Will my new TAR.GZ be bigger than the TAR.BZ it came from?
Usually, yes, since gzip's narrower 32 KB window generally can't match bzip2's wider 900 KB block-based matching on repetitive text, though the exact difference depends heavily on the actual content.
Can gzip's reported uncompressed size be wrong?
Yes, for files 4 GB or larger. Gzip's ISIZE field is only 32 bits and stores the original size modulo 2^32, a documented limitation of RFC 1952 itself, not a bug in a specific tool.
Is pigz worth using instead of plain gzip for this conversion?
For large archives on multi-core hardware, yes — pigz can meaningfully cut compression time by spreading the work across CPU cores, while producing output any standard gzip tool reads normally.
Does pigz also speed up decompression?
Not meaningfully. Pigz's own documentation notes decompression isn't parallelized the same way compression is, since DEFLATE decompression is a more inherently sequential process.
Does this conversion change any files inside the archive?
No. Only the compression method wrapped around the tar stream changes; every file, permission, and timestamp inside comes out identical after extraction either way.