How to Create Magnet Link from Torrent Info Hash
A raw 40-character torrent info hash is the cryptographic identifier for a torrent’s metadata, and it can be easily converted into a fully functional magnet link using the standard Magnet URI scheme. By appending the 40-character hexadecimal string to the base BitTorrent uniform resource name (URN), you create a valid link that any modern BitTorrent client can recognize. While the bare hash is sufficient for clients operating on a Distributed Hash Table (DHT) network, you can also append optional parameters such as display names and tracker URLs to speed up peer discovery.
The Basic Magnet Link Structure
The absolute minimum requirement for a valid BitTorrent magnet link
is the Magnet URI scheme prefix, the exact topic parameter
(xt), and the BitTorrent Info Hash URN prefix
(urn:btih:).
The standard syntax is:
magnet:?xt=urn:btih:<40-character-hash>
Step-by-Step Construction
- Obtain the 40-Character Hash: Ensure the hash is a
40-character hexadecimal string (using characters
0-9anda-forA-F). Example:4a7e93540974b7b2520da08b1a8dc7ec1cfc5c7d - Prepend the Base URI: Place
magnet:?xt=urn:btih:immediately before the hash without spaces. - Assemble the Minimal Link:
magnet:?xt=urn:btih:4a7e93540974b7b2520da08b1a8dc7ec1cfc5c7d
This minimal link can be pasted directly into clients like qBittorrent, Transmission, or Deluge to locate peers via the DHT network.
Adding Optional Parameters
To improve connection speed and user experience, you can append
additional metadata using standard URL query formatting
(¶meter=value). All values should be
URL-encoded.
- Display Name (
dn): Adds a recognizable file or folder name before metadata is downloaded.- Parameter:
&dn=Example+Torrent+Name
- Parameter:
- Tracker URLs (
tr): Specifies public tracker servers to find peers faster without relying solely on DHT.- Parameter:
&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce
- Parameter:
Complete Example
Combining the hash, a display name, and a public tracker results in a robust magnet link:
magnet:?xt=urn:btih:4a7e93540974b7b2520da08b1a8dc7ec1cfc5c7d&dn=Example+Torrent+Name&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce