Skip to content

AV1 Image File Format (.avif)

.avif file signature | image/avif

AV1 Image File Format (AVIF), based on the open sourceAlliance for Open Media(AOMedia)Video 1 (AV1) codec.

Safe

Magic Bytes

Offset 4
66 74 79 70 61 76 69 66

Sources: Apache Tika, Gary Kessler

Extension

.avif

MIME Type

image/avif

Byte Offset

4

Risk Level

Safe

Validation Code

How to validate .avif files in Python

Python
def is_avif(file_path: str) -> bool:
    """Check if file is a valid AVIF by magic bytes."""
    signature = bytes([0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66])
    with open(file_path, "rb") as f:
        return f.read(8) == signature

How to validate .avif files in Node.js

Node.js
function isAVIF(buffer: Buffer): boolean {
  const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66]);
  return buffer.subarray(0, 8).equals(signature);
}

How to validate .avif files in Go

Go
func IsAVIF(data []byte) bool {
    signature := []byte{0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66}
    if len(data) < 8 {
        return false
    }
    return bytes.Equal(data[:8], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .avif file?

A .avif file is a AV1 Image File Format file. AV1 Image File Format (AVIF), based on the open sourceAlliance for Open Media(AOMedia)Video 1 (AV1) codec.

What are the magic bytes for .avif files?

The magic bytes for AV1 Image File Format files are 66 74 79 70 61 76 69 66 at byte offset 4. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .avif file?

To validate a .avif file, read the first bytes of the file and compare them against the known magic bytes (66 74 79 70 61 76 69 66) at offset 4. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .avif files?

The primary MIME type for .avif files is image/avif.

Is it safe to open .avif files?

AV1 Image File Format (.avif) 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.