Graphics interchange format file (.gif)
.gif file signature | image/gif
Graphics Interchange Format (GIF) is a raster image file format created by CompuServe and later standardized and maintained by the broader internet standards community. It is commonly used for simple graphics, logos, short animations, and web images with limited color palettes. GIF is a mature format with broad support across platforms, and while generally safe, files from untrusted sources may still be used to conceal malicious content or exploit parser flaws in image software.
Magic Bytes
Offset 0
47 49 46 38 37 61
Sources: Apache Tika, Wikipedia, Gary Kessler
All Known Signatures
3 signature variants are documented for .gif files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 47 49 46 38 37 61 | 0 | Apache Tika, Wikipedia, Gary Kessler |
| 47 49 46 38 39 61 | 0 | Apache Tika, Wikipedia, Gary Kessler |
| 47 49 46 38 | 0 | Neil Harvey FileSignatures |
Extension
.gif
MIME Type
image/gif
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .gif files in Python
def is_gif(file_path: str) -> bool:
"""Check if file is a valid GIF by magic bytes."""
signature = bytes([0x47, 0x49, 0x46, 0x38, 0x37, 0x61])
with open(file_path, "rb") as f:
return f.read(6) == signature
How to validate .gif files in Node.js
function isGIF(buffer: Buffer): boolean {
const signature = Buffer.from([0x47, 0x49, 0x46, 0x38, 0x37, 0x61]);
return buffer.subarray(0, 6).equals(signature);
}
How to validate .gif files in Go
func IsGIF(data []byte) bool {
signature := []byte{0x47, 0x49, 0x46, 0x38, 0x37, 0x61}
if len(data) < 6 {
return false
}
return bytes.Equal(data[:6], signature)
}
API Endpoint
/api/v1/gif
curl https://filesignature.org/api/v1/gif
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .gif file?
A .gif file is a Graphics interchange format file file. Graphics Interchange Format (GIF) is a raster image file format created by CompuServe and later standardized and maintained by the broader internet standards community. It is commonly used for simple graphics, logos, short animations, and web images with limited color palettes. GIF is a mature format with broad support across platforms, and while generally safe, files from untrusted sources may still be used to conceal malicious content or exploit parser flaws in image software.
What are the magic bytes for .gif files?
The magic bytes for Graphics interchange format file files are 47 49 46 38 37 61 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .gif file?
To validate a .gif file, read the first bytes of the file and compare them against the known magic bytes (47 49 46 38 37 61) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .gif files?
The primary MIME type for .gif files is image/gif.
Is it safe to open .gif files?
Graphics interchange format file (.gif) 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.