Skip to content

Rar4 (.rar)

.rar file signature | application/vnd.rar

Roshal ARchivecompressed archive v1.50 onwards[23]

Safe

Magic Bytes

Offset 0
52 61 72 21 1A 07 00

Sources: Wikipedia, Gary Kessler, Neil Harvey FileSignatures

All Known Signatures

4 signature variants are documented for .rar files across multiple sources.

Hex Signature Offset Sources
52 61 72 21 1A 07 00 0 Wikipedia, Gary Kessler, Neil Harvey FileSignatures
52 61 72 21 1A 07 01 00 0 Wikipedia, Gary Kessler, Neil Harvey FileSignatures
52 61 72 21 0 Apache Tika
52 61 72 21 1A 0 Apache Tika

Extension

.rar

MIME Type

application/vnd.rar, application/x-rar-compressed

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .rar files in Python

Python
def is_rar(file_path: str) -> bool:
    """Check if file is a valid RAR by magic bytes."""
    signature = bytes([0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00])
    with open(file_path, "rb") as f:
        return f.read(7) == signature

How to validate .rar files in Node.js

Node.js
function isRAR(buffer: Buffer): boolean {
  const signature = Buffer.from([0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00]);
  return buffer.subarray(0, 7).equals(signature);
}

How to validate .rar files in Go

Go
func IsRAR(data []byte) bool {
    signature := []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}
    if len(data) < 7 {
        return false
    }
    return bytes.Equal(data[:7], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .rar file?

A .rar file is a Rar4 file. Roshal ARchivecompressed archive v1.50 onwards[23]

What are the magic bytes for .rar files?

The magic bytes for Rar4 files are 52 61 72 21 1A 07 00 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .rar file?

To validate a .rar file, read the first bytes of the file and compare them against the known magic bytes (52 61 72 21 1A 07 00) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .rar files?

The primary MIME type for .rar files is application/vnd.rar. Additional MIME types include: application/vnd.rar, application/x-rar-compressed.

Is it safe to open .rar files?

Rar4 (.rar) 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.