BZ2

application/octet-stream

Safe

Magic Bytes

Offset: 0
42 5A 68

Bzip2 is a free and open-source lossless data compression algorithm and file format developed by Julian Seward using the Burrows-Wheeler transform. It is primarily employed in Unix-like environments for compressing individual files, software distributions, and system logs to achieve high compression ratios. Although newer formats like XZ have largely superseded it in modern Linux distributions, Bzip2 remains widely supported and is considered safe due to its lack of executable content.

Extension

.bz2

MIME Type

application/octet-stream

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .bz2 files in Python

Python
def is_bz2(file_path: str) -> bool:
    """Check if file is a valid BZ2 by magic bytes."""
    signature = bytes([0x42, 0x5A, 0x68])
    with open(file_path, "rb") as f:
        return f.read(3) == signature

How to validate .bz2 files in Node.js

Node.js
function isBZ2(buffer: Buffer): boolean {
  const signature = Buffer.from([0x42, 0x5A, 0x68]);
  return buffer.subarray(0, 3).equals(signature);
}
Go
func IsBZ2(data []byte) bool {
    signature := []byte{0x42, 0x5A, 0x68}
    if len(data) < 3 {
        return false
    }
    return bytes.Equal(data[:3], signature)
}

API Endpoint

GET /api/v1/bz2
curl https://filesignature.org/api/v1/bz2

Related Formats