Skip to content

LZ4 (.lz4)

.lz4 file signature | application/x-lz4

LZ4 Frame Format[62]Remark: LZ4 block format does not offer any magic bytes.[63]

Safe

Magic Bytes

Offset 0
18 4D 22 04

Sources: Apache Tika

All Known Signatures

2 signature variants are documented for .lz4 files across multiple sources.

Hex Signature Offset Sources
18 4D 22 04 0 Apache Tika
18 4C 21 02 0 Apache Tika

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);
}

How to validate .lz4 files in Go

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .lz4 file?

A .lz4 file is a LZ4 file. LZ4 Frame Format[62]Remark: LZ4 block format does not offer any magic bytes.[63]

What are the magic bytes for .lz4 files?

The magic bytes for LZ4 files are 18 4D 22 04 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .lz4 file?

To validate a .lz4 file, read the first bytes of the file and compare them against the known magic bytes (18 4D 22 04) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .lz4 files?

The primary MIME type for .lz4 files is application/x-lz4.

Is it safe to open .lz4 files?

LZ4 (.lz4) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.