BitTorrent Metainfo
A .torrent file is a bencoded metadata file containing tracker URLs, file listings, and SHA-1 piece hashes used by BitTorrent clients to coordinate peer-to-peer downloads.
BitTorrent metadata file. Not a data format that can be converted.
Common questions
How do I inspect the contents of a .torrent file without downloading anything?
Use a tool like `transmission-show` on Linux or open the file in a BitTorrent client like qBittorrent, which displays metadata (file list, piece size, tracker URL) before starting any download. Since .torrent files are bencoded text, you can also decode them with Python's bencodepy library to read the raw structure.
What is an info_hash and why does it matter?
The info_hash is a SHA-1 digest of the bencoded info dictionary inside the .torrent file. It uniquely identifies a torrent across the entire BitTorrent network. Clients send this hash to trackers and DHT nodes to find other peers sharing the same content. Changing any byte in the info dict produces a different hash, effectively creating a different torrent.
What is the difference between a .torrent file and a magnet link?
A .torrent file contains the full metadata including piece hashes and file structure. A magnet link contains only the info_hash and optionally tracker URLs, requiring the client to download the metadata from peers before it can begin the actual transfer. Magnet links are more convenient to share but depend on DHT or trackers to bootstrap.
Can a .torrent file become outdated?
The file metadata (names, sizes, piece hashes) never changes, but tracker URLs can go offline. If all trackers listed in the announce and announce-list fields are unreachable and no peers are available via DHT, the client cannot find the swarm. The content itself may also become unavailable if no seeders remain.
What makes .TORRENT special
BitTorrent metainfo files act as instruction sets that tell a client where to find peers and how to verify downloaded data. Torrent files use bencoding, a simple serialization format invented by Bram Cohen that represents data as dictionaries (d...e), lists (l...e), integers (i...e), and byte strings (length:data) -- the entire .torrent file is a single bencoded dictionary containing tracker URLs and SHA-1 piece hashes.
Continue reading — full technical deep dive
Bencoded Structure
The top-level dictionary always contains an info key whose value is another dictionary describing the shared content. For single-file torrents, the info dict holds name, piece length, length, and pieces (a concatenation of 20-byte SHA-1 hashes, one per piece). Multi-file torrents replace length with a files list, where each entry specifies a path array and length. The file has no fixed magic bytes; it simply starts with the ASCII character d (0x64), the bencoding marker for dictionary.
Tracker Communication and info_hash
The announce key holds the primary tracker URL. An optional announce-list provides fallback trackers in tiered priority. Clients compute the info_hash by taking the SHA-1 digest of the raw bencoded info dictionary. This 20-byte hash uniquely identifies the torrent across the entire BitTorrent network and is sent to trackers during announce requests to find peers sharing the same content.
Magnet Links and Trackerless Operation
Magnet links encode the info_hash as a URN, eliminating the need for a .torrent file entirely. The client uses Distributed Hash Table (DHT) lookups to discover peers from the info_hash alone. Peer Exchange (PEX) supplements DHT by allowing connected peers to share addresses of other known peers. Together, DHT and PEX enable fully trackerless swarm formation.
Piece Verification
After downloading each piece, the client computes its SHA-1 hash and compares it against the corresponding 20-byte entry in the pieces field. Any mismatch triggers a re-download of that piece from a different peer. This per-piece integrity check means corrupted or tampered data is caught immediately, long before the full download completes. Typical piece sizes range from 256 KiB to 4 MiB, chosen by the torrent creator to balance verification overhead against metadata size.
Technical reference
- MIME Type
application/x-bittorrent- Magic Bytes
64 38 3AStarts with bencoded dictionary (d8: for 8-char announce key).- Developer
- Bram Cohen
- Year Introduced
- 2001
- Open Standard
- Yes — View specification
Starts with bencoded dictionary (d8: for 8-char announce key).
Binary Structure
A bencoded dictionary starting with byte 0x64 ('d'), containing string keys mapped to bencoded values. The top-level dictionary holds announce URLs and an info dictionary with piece length, SHA-1 piece hashes, and file metadata, all terminated by the byte 0x65 ('e').
Attack Vectors
- Tracker URL fields pointing to internal network addresses for SSRF if a client blindly resolves announce URLs
- Misleading file path entries in multi-file torrents that use directory traversal sequences (e.g., ../../../etc/passwd) to write outside the download directory
Mitigation: FileDex does not parse, render, or execute these files. Reference page only.