Torrent file (.torrent)
.torrent file signature | application/x-bittorrent
Torrent files are metadata files used by the BitTorrent peer-to-peer protocol, originally introduced by Bram Cohen and maintained through the BitTorrent specification ecosystem. They are used by BitTorrent clients to locate content, coordinate downloads, and verify file pieces for software distribution, media sharing, and other large transfers. The format is generally safe, though torrents may reference untrusted content, and files obtained through them can expose users to copyright, privacy, or malware risks.
Magic Bytes
Offset 0
64 38 3A 61 6E 6E 6F 75 6E 63 65
Sources: Apache Tika, Gary Kessler
Extension
.torrent
MIME Type
application/x-bittorrent
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .torrent files in Python
def is_torrent(file_path: str) -> bool:
"""Check if file is a valid TORRENT by magic bytes."""
signature = bytes([0x64, 0x38, 0x3A, 0x61, 0x6E, 0x6E, 0x6F, 0x75, 0x6E, 0x63, 0x65])
with open(file_path, "rb") as f:
return f.read(11) == signature
How to validate .torrent files in Node.js
function isTORRENT(buffer: Buffer): boolean {
const signature = Buffer.from([0x64, 0x38, 0x3A, 0x61, 0x6E, 0x6E, 0x6F, 0x75, 0x6E, 0x63, 0x65]);
return buffer.subarray(0, 11).equals(signature);
}
How to validate .torrent files in Go
func IsTORRENT(data []byte) bool {
signature := []byte{0x64, 0x38, 0x3A, 0x61, 0x6E, 0x6E, 0x6F, 0x75, 0x6E, 0x63, 0x65}
if len(data) < 11 {
return false
}
return bytes.Equal(data[:11], signature)
}
API Endpoint
/api/v1/torrent
curl https://filesignature.org/api/v1/torrent
See the full API documentation for all endpoints and parameters.
Frequently Asked Questions
What is a .torrent file?
A .torrent file is a Torrent file file. Torrent files are metadata files used by the BitTorrent peer-to-peer protocol, originally introduced by Bram Cohen and maintained through the BitTorrent specification ecosystem. They are used by BitTorrent clients to locate content, coordinate downloads, and verify file pieces for software distribution, media sharing, and other large transfers. The format is generally safe, though torrents may reference untrusted content, and files obtained through them can expose users to copyright, privacy, or malware risks.
What are the magic bytes for .torrent files?
The magic bytes for Torrent file files are 64 38 3A 61 6E 6E 6F 75 6E 63 65 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .torrent file?
To validate a .torrent file, read the first bytes of the file and compare them against the known magic bytes (64 38 3A 61 6E 6E 6F 75 6E 63 65) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .torrent files?
The primary MIME type for .torrent files is application/x-bittorrent.
Is it safe to open .torrent files?
Torrent file (.torrent) 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.