:: bzip3

iczelia

A better and stronger spiritual successor to BZip2.

recent commits

2026-11-10 22:37progress on #160, #152, #143.Kamila Szewczyk
2026-11-10 21:12reorganise the codeKamila Szewczyk
2026-11-10 02:07remove RLE from the encoder pathsKamila Szewczyk
2026-11-09 23:59runtime kernel detectionKamila Szewczyk
2026-11-09 23:23v1.5.6Kamila Szewczyk
2026-10-22 17:50install pkg-config in ciKamila Szewczyk
2026-10-22 17:29fix #193Kamila Szewczyk
2026-10-22 10:32v1.5.5Kamila Szewczyk
2026-10-18 10:37fix #191, #192Kamila Szewczyk
2026-10-14 06:17stricter checks at boundaries for bz3_decode and cliKamila Szewczyk

branches

master (2026-11-10 22:37)e8e9 (2022-07-31 14:45)

tags

1.5.5 (2026-10-22 10:32)1.5.4 (2026-09-07 19:52)1.5.3 (2025-08-13 09:26)1.5.2 (2025-04-27 12:16)1.5.1 (2024-12-16 15:00)1.5.0 (2024-12-15 10:53)1.4.0 (2023-12-06 17:13)1.3.2 (2023-08-06 08:20)1.3.1 (2023-05-20 07:59)1.3.0 (2023-04-03 19:26)1.2.3 (2023-03-24 13:58)1.2.2 (2023-01-10 14:43)1.2.1 (2022-11-09 12:19)1.2.0 (2022-10-30 07:10)1.1.8 (2022-10-25 15:18)1.1.7 (2022-10-23 14:44)

all tags >>

README.md

bzip3 ⎇

Build

A better, faster and stronger spiritual successor to bzip2. It compresses better and runs faster thanks to an order-0 context mixing entropy coder, a fast Burrows-Wheeler transform built on suffix arrays, and a Lempel-Ziv prediction pass based on LZ77-style string matching and PPM-style context modeling.

bzip3 is licensed under the GNU Lesser GPL version 3 or later. See COPYING and AUTHORS. Report issues at <https://github.com/iczelia/bzip3>.

Quick start ⎇

bzip3 file              # writes file.bz3
bzip3 -d file.bz3       # restores file
bzip3 -B -j 4 *.txt     # process every file, four blocks at a time
tar c dir | bzip3 -b 64 > dir.tar.bz3
bz3cat dir.tar.bz3 | tar x

Encoding is the default setting. -d decompresses and -t checks a file. With one file name, the output name is derived by adding or removing .bz3; a second name is the output, and -c writes to the standard output. -B treats every name as an input. Existing files are kept unless -f is given, and --rm removes the inputs once they were processed.

-b sets the block size in MiB, from 1 to 511; the default is 16. Larger blocks compress better and need about six times their size in memory, to compress and to decompress. -j codes that many blocks at once.

The bunzip3, bz3cat, bz3less, bz3more, bz3most and bz3grep scripts work like their bzip2 namesakes. See bzip3(1).

Installation ⎇

Use your package manager or download a release from GitHub Releases.

Packaging status

To build a release tarball, run

./configure
make
make check
sudo make install

The project uses C99 and, for -j, POSIX or Windows threads. libsais is bundled unmodified in 3rdparty/libsais.

Configure optionEffect
--enable-sanitizersEnable ASan and UBSan for tests
--disable-simdBuild the portable CRC-32C only
--disable-threadsCode the blocks of -j and bz3_encode_blocks one at a time
--enable-static-exeLink bzip3 statically
--disable-shared, --disable-staticChoose the kinds of libbzip3 to build

Run ./bootstrap first when building from a Git checkout. It requires autoconf, automake and libtool. The version comes from git describe, so a checkout needs its tags.

The build is portable by default: pass CFLAGS="-O2 -march=native" to configure to tune it for the machine it is built on.

Library ⎇

libbzip3 and its header libbz3.h are installed with the tool, with a pkg-config file:

cc example.c $(pkg-config --cflags --libs bzip3)

bz3_compress and bz3_decompress code a buffer in one call; bz3_encode_block and bz3_decode_block code single blocks and are what the tool is built on. include/libbz3.h documents them and examples/hl-api.c uses them. The format is described in doc/bzip3_format.md.

Every release reads the files of the releases before it. The shared library exports only the functions of libbz3.h, and the static library defines no symbol outside of the bz3_ namespace.

Performance and portability ⎇

Files are portable across hosts and byte orders. The checksum is CRC-32C; on x86 and 64-bit ARM a kernel using the CPU's CRC instructions is built next to the portable one and chosen at run time when the CPU has them.

Windows builds use MinGW as follows:

./configure --host=x86_64-w64-mingw32 CC=x86_64-w64-mingw32-gcc --enable-static-exe
make

Testing and fuzzing ⎇

make check runs unit tests of the coders, tests of the library interface and of the command line tool, and decodes reference files written by bzip3 1.5.5. make check-full and make check-torture code more data.

fuzz/build.sh builds libFuzzer harnesses for the block decoder, the frame decoder and the round trip with ASan and UBSan; FZ_SAN=msan and FZ_SAN=standalone select MemorySanitizer or a plain tool that replays inputs.

tab: 248 wrap: offon