BZ2

What is a BZ2 file?

Compresses better than GZ and takes noticeably longer doing it.

What BZ2 is

BZ2 is a stream format, written and read from front to back. It is used for archiving.

The extension is .bz2, and the full name is Bzip2 Archive. Both matter less than what the file can hold, which is what the rest of this page is about.

Where BZ2 came from

It dates from 1996.

A format that has been readable for that long is a format worth trusting with something you want back in ten years.

The specification is public

It is published in full, so anyone can implement it from the document rather than by inspection, which is why it turns up in so many programs and why files written twenty years ago still open. A published specification is not the same thing as a royalty-free one: where a format wraps a codec, the patent licensing is a separate question the standard does not settle.

It is a legacy format

It still opens everywhere and is still written by older tools, but nothing new is being built around it. Convert what you mean to keep, and do not choose it for something starting today.

Nothing is thrown away

BZ2 stores its content exactly. Saving it again changes nothing, so it can be opened, edited and re-saved as often as you like without accumulating damage — which is what makes it a working format rather than a delivery one.

It holds exactly one file

BZ2 compresses a single stream and has no concept of a filename or a folder. That is why it is so often seen paired with TAR, which supplies the structure it lacks.

Where its compression ratio comes from

It works over 900 KB at a time: the span of data repetition has to fall inside before it can be compressed away.

That single number explains most of the difference between one archive format and another. A larger span finds more repetition and takes longer and more memory to do it, which is the whole trade.

What it does to protect itself

BZ2 carries a checksum, so a damaged file is detected rather than silently mis-read.

A checksum will not repair anything. It tells you the file is wrong, which is the difference between finding out now and finding out from whoever you sent it to.

What opens BZ2

bzip2, 7-Zip and Keka read it, and so do most programs of the same kind.

If a file will not open, the format is rarely the problem — it is more often that the program predates it. Converting to something older is the reliable way past that, and it is what the rest of this site is for.

Opening it in a browser

No browser reads it.

That is the single most common reason to convert it: not that the format is bad, but that the place you want to show the file cannot read it.

It is a delivery format

BZ2 is meant to be handed over rather than worked in. Editing one is possible and rarely pleasant; the sane approach is to change the source and export again.

What goes wrong with it

The recurring complaints: it holds one stream and cannot describe a folder.

None of these is a reason to avoid the format. They are the things worth knowing before you are surprised by one, which is a different claim and a more useful one.

Squeezed out from both sides, and worth saying so

Bzip2 arrived in 1996 compressing noticeably better than gzip, and for about a decade `.tar.bz2` was the sensible middle choice for source releases and archives. That period is over. xz compresses harder, zstd is faster at similar ratios, and both decompress more quickly than bzip2 does.

So a `.bz2` you encounter today is almost always old — an archived release, a dataset published years ago, a backup from a system whose defaults were set in 2008. There is no live argument for creating new ones, and the useful question is how to open the one you have.

It sorts the data instead of searching it

Every other compressor here — gzip, xz, 7z, zip — looks backwards for repeated sequences. Bzip2 does something different: the Burrows-Wheeler transform rearranges a block of data so that similar characters end up adjacent, then a simple encoder exploits the runs that creates.

The transform is reversible, which is the surprising part — the rearrangement can be undone exactly. It is an elegant approach and it explains the format’s characteristics: good ratios on text, slow decompression because the transform must be reversed, and a memory cost proportional to the block size rather than to the file.

Blocks, which make it recoverable

Bzip2 works on independent blocks, by default 900 KB each. Every block compresses and decompresses on its own without reference to its neighbours.

That gives it a property nothing else here has: if part of an archive is corrupted, the undamaged blocks are still readable, and a recovery tool can extract them. In gzip or xz, damage early in the stream usually costs everything after it. For an old archive on failing media, that is a genuine advantage and occasionally a decisive one.

And make it parallel

Because blocks are independent, they can be compressed and decompressed on separate processor cores at the same time. Tools such as pbzip2 and lbzip2 exploit this and produce files that ordinary bzip2 still reads.

On a machine with eight cores that turns bzip2’s worst characteristic into something tolerable. It is the main reason the format survived as long as it did in scientific computing and data pipelines, where files are large and cores are plentiful.

The double extension, again

Bzip2 compresses exactly one stream. It has no directory, no file names, no notion of several files — the same shape as gzip and xz. That is why `.tar.bz2` is the normal form: tar bundles the tree into one stream and bzip2 compresses it.

Decompressing a bare `.bz2` gives back exactly one file. If you expected a folder, the archive you wanted is the `.tar` inside, and most tools present the two steps as one.

Where the numbers actually land

On typical text and source code, bzip2 lands roughly a quarter smaller than gzip — 25 and 27 per cent on two source corpora measured for this page — and within a few per cent of xz on that kind of input. Compression is several times slower than gzip; decompression is slower still, which is the characteristic that ended it.

That last point is what makes the format unattractive rather than merely superseded. A file is compressed once and decompressed many times, so a format that is slow to read pays its cost repeatedly. xz is slow to write and fast to read, which is the correct way round.

It has been unmaintained, and that mattered

The original bzip2 went years without a release, and in 2019 an out-of-bounds write was found in the decompressor that had been present for a long time. Maintenance has since been picked up and the issue is fixed everywhere current.

It is worth knowing for context rather than as a warning about your files: a `.bz2` is data, not code, and opening one with up-to-date software is unremarkable. The episode is part of why distributions moved on, alongside the speed.

What still produces one

Older Linux source releases and archived distribution packages. Scientific and genomic datasets, where the block-parallel tools made it practical and where published archives do not get re-encoded. Backup systems configured a decade ago. Wikipedia’s database dumps, historically and for a long time.

The pattern is publication rather than exchange: files written once, downloaded by many, and never revisited. Nobody sends a colleague a `.bz2` today.

Opening it, and what to do next

Every Linux and macOS system handles bzip2 from the command line, and 7-Zip reads it on Windows without difficulty. Decompressing a `.tar.bz2` is two steps most tools present as one.

If the contents are going onward to a person, repackage as ZIP — it is what their computer opens without help. If they are going back to a Unix system, repackage as `.tar.gz` or `.tar.xz`, which preserve the permissions and symbolic links that tar carried and that ZIP discards. Re-creating a `.bz2` is the one option with nothing to recommend it.

The facts, in one place

Identifiers and provenance for the BZ2 format.
Extension.bz2
Media typeapplication/x-bzip2
First published1996