BitTorrent Specification
Written and maintained by Kevin Hearn (kh@tixati.com)
Last update October 7, 2025
This is a general specification intended to help anyone who wants to create their own BitTorrent client. If you would like to make corrections, comments, or have questions, please visit the
specifications forum.
Info
The torrent "info", sometimes also called the "info dict" or "info key", defines the file structure of the torrent. It is hashed to form the "info hash", which is used to identify one torrent from another when interacting with trackers, the DHT, and other peers.
Peer Connections
Peers connect to each other using a simple message passing protocol. There are several sub-protocols and extensions. There are also many transport options such as encryption and UDP.
Trackers
Trackers are centralized services that are used to find other peers in a torrent. There is a simple HTTP query/answer protocol as well as a more efficient UDP protocol.
DHT
DHT stands for Distributed Hash Table. It serves the same purpose as trackers, but operates in a highly decentralized way.
Web Seeds
Web seeds are treated like regular peers, but they download via HTTP protocol from a file on a conventional web server.
Partial Downloads
A multi-file torrent can be only downloaded partially and then seeded.
Private Torrents
This extension disables PEX and DHT access for a torrent so that peer participation can be tightly controlled by a tracker.
BEncode Format
BEncode is an integer/string/map/list representation format that can be nested.
Magnet Links
There are several different attributes that can go into a magnet link in addition to the info hash ID.
.torrent Files
These files contain the torrent info combined with tracker addresses and web seed addresses.
Padding Files
Padding files are used in multi-file torrents to align the beginning of files to piece boundaries.
Problems With SHA-1
The hashing algorithm SHA-1 is used throughout the BitTorrent protocol. There are attacks that can be made based upon the weakness of this hash.
BitTorrent SHA-1 Collision Demo
This simple demonstration includes two different files that produce the same info hash.
Protocol Version 3
This set of simple and fully backward-compatible improvements eliminates weaknesses caused by the use of the SHA-1 hashing algorithm.
Protocol Version 3.1
This set of improvements fully retires SHA-1, provides cryptographic agility, prevents DHT sniffing, and keeps file meta info private to only those that have a magnet link.