100% Client-Side Privacy
Adawaty Pro • adawaty-pro.com
48+ Offline Client-Side Converters & Technical Guides
Home / Dev & Config Formats / TORRENT to MAGNET / JSON
Read Technical Guides →

TORRENT to MAGNET / JSON

Decode .torrent Bencode, compute SHA-1 info_hash & extract Magnet link + files — 100% private client-side processing.

100% Client-Side JS

Active Converter

Smart Auto-Fix:
1. Source File(s) or Paste Input: No file selected
2. Live Output (Editable):
BEP-0003 Bencode Decoding & WebCrypto SHA-1 InfoHash

TORRENT to MAGNET / JSON: Computing BitTorrent Info-Hashes & File Trees Locally

Technical Anatomy of Bencoded .TORRENT Files

Defined in BEP-0003 (BitTorrent Specification), a .torrent file is a compact Bencode binary dictionary. Bencode supports just four data types: byte strings prefixed with decimal length (8:announce), integers delimited by i...e (i262144e), lists (l...e), and lexicographically sorted dictionaries (d...e).

Inside the root dictionary sits the critical 4:info sub-dictionary containing the torrent name, piece length, concatenated 20-byte SHA-1 piece hashes, and either a single file length or a files list. To generate an authentic Magnet URI (magnet:?xt=urn:btih:<40-hex-hash>&dn=...&tr=...), our parser records the exact start and end byte offsets of the raw info dictionary and feeds that exact slice to crypto.subtle.digest('SHA-1', infoSlice).

Raw Bencode Metadata vs. Generated Magnet Link & JSON

# Input: Raw Bencode Prefix (ubuntu-24.04-desktop.torrent)
d8:announce39:https://torrent.ubuntu.com/announce4:infod6:lengthi6123456789e4:name23:ubuntu-24.04-amd64.iso...e

# Computed Magnet Link & JSON Output:
magnet:?xt=urn:btih:2c6b6858d61da9543d4231a71db4b1c9264b0685&dn=ubuntu-24.04-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce

Real-World Software & Hardware Ecosystem

Linux ISO mirrors, open-dataset researchers (Academic Torrents, Internet Archive), and seedbox users convert .torrent files into lightweight Magnet links or JSON file inventories for qBittorrent, Transmission, Deluge, aria2c, and mobile clients without keeping dozens of .torrent files cluttering their downloads folder.

Troubleshooting & Edge Cases

  • BitTorrent v2 Hybrid Torrents (BEP-0052): Newer v2-only torrents use SHA-256 btmh hashes and a file tree dictionary instead of v1 files; hybrid torrents carry both v1 SHA-1 and v2 metadata so standard btih Magnet links still work universally.
  • Preserving Raw Info Bytes: Re-encoding the info dictionary with slightly different key ordering changes the SHA-1 hash completely. Our decoder slices the original raw bytes directly so the btih hash matches qBittorrent 100%.
  • Batch Converting Multiple .TORRENT Files: Drop a folder of .torrent files to extract every Magnet URI and JSON file tree in a single Batch ZIP download.

BEP-0003 Bencode Grammar Reference

Bencode Type Syntax Pattern Concrete Example
Byte String<len>:<bytes>4:info
Integeri<base10>ei262144e (256 KB piece)
Listl<items>el4:docs9:README.mde
Dictionaryd<key><val>ed6:lengthi1024ee

Step-by-Step SHA-1 Info-Hash Derivation

  1. Locate the 4:info Key: Our streaming Bencode parser traverses the root dictionary without converting binary piece hashes to UTF-8 strings (which would corrupt high bytes >= 0x80).
  2. Slice Exact Raw Bytes: The parser records the starting byte offset of the info dictionary's opening d and its matching closing e.
  3. Hash via WebCrypto SHA-1: That exact byte slice is passed to crypto.subtle.digest('SHA-1', infoBytes) to yield the 20-byte (40-hex-character) urn:btih hash.
  4. Assemble RFC 3986 Magnet URI: The display name (dn) and tracker URLs (tr) are percent-encoded and appended into a ready-to-click Magnet link.

Understanding Piece Length, Tracker Lists & DHT Discovery

Every .torrent splits its payload into fixed-size cryptographic chunks—commonly 256 KB, 1 MB, or 4 MB—declared by piece length inside the info dictionary. Each piece has a 20-byte SHA-1 hash concatenated into the binary pieces field so P2P clients verify every downloaded block against corruption automatically.

When you convert a .torrent into a Magnet URI, the link carries only the 40-character btih hash, display name (dn), and optional tracker URLs (tr); the client then fetches the full info dictionary on demand from peers via BEP-0009 metadata exchange over DHT. Exporting the JSON file tree locally first lets you verify exact filenames and total gigabytes before adding the Magnet link to qBittorrent, Transmission, or aria2c.

Remember that public DHT discovery works best when a Magnet URI includes at least two active UDP or HTTPS announce trackers alongside the btih hash. When archiving Linux distribution releases for offline lab networks, keeping both the lightweight Magnet link and the exported JSON file manifest provides instant cryptographic verification of every filename and byte count.

Frequently Asked Questions

How is a BitTorrent Magnet URI (magnet:?xt=urn:btih:...) computed directly from a .TORRENT file?

A .torrent file is encoded in Bencode—a binary-safe format of dictionaries (d...e), lists (l...e), integers (i...e), and length-prefixed byte strings (4:info). Our client-side Bencode decoder locates the exact raw byte slice of the 'info' dictionary and hashes it with WebCrypto SHA-1 to produce the 40-character hexadecimal info_hash.

Can I inspect the complete list of files and exact byte sizes inside a .TORRENT before opening a torrent client?

Yes. Export to .JSON or preview in the workbench to see the torrent's display name, announce tracker URLs, piece length, and every file path + size listed inside single-file or multi-file info.files dictionaries.

Why did a private tracker .TORRENT include a 'private: 1' flag?

Private trackers set info.private = 1 inside the Bencode dictionary to instruct clients like qBittorrent or Transmission to disable DHT and Peer Exchange (PEX). Note that Magnet links omit private passkey data unless the announce URL is appended.

Does this tool download any torrent content or connect to peers?

No. It strictly parses the tiny local .torrent metadata file in your browser to extract the Magnet link, SHA-1 info_hash, trackers, and file manifest—making zero P2P network connections.