LZ4

application/x-lz4

Safe

Magic Bytes

Offset: 0
18 4D 22 04

LZ4 is a lossless data compression algorithm and file format developed by Yann Collet, specifically designed to prioritize compression and decompression speed. It is extensively utilized in operating system kernels, filesystem compression, real-time data streaming, and high-performance computing scenarios where throughput is critical. As an open-source standard widely adopted within the Linux ecosystem, the format is considered safe and stable for general use without specific security vulnerabilities.

Extension

.lz4

MIME Type

application/x-lz4

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .lz4 files in Python

Python
def is_lz4(file_path: str) -> bool:
    """Check if file is a valid LZ4 by magic bytes."""
    signature = bytes([0x18, 0x4D, 0x22, 0x04])
    with open(file_path, "rb") as f:
        return f.read(4) == signature

How to validate .lz4 files in Node.js

Node.js
function isLZ4(buffer: Buffer): boolean {
  const signature = Buffer.from([0x18, 0x4D, 0x22, 0x04]);
  return buffer.subarray(0, 4).equals(signature);
}
Go
func IsLZ4(data []byte) bool {
    signature := []byte{0x18, 0x4D, 0x22, 0x04}
    if len(data) < 4 {
        return false
    }
    return bytes.Equal(data[:4], signature)
}

API Endpoint

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

Related Formats