node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



Read and parse a torrent from a resource

npm install read-torrent


var readTorrent = require('read-torrent');
readTorrent('', options, function(err, torrent) {
    // we loaded a torrent from a server 
readTorrent('mydir/file.torrent', function(err, torrent) {
    // we loaded a torrent from a file 

where options is a javascript object with request options

The torrent result looks like this:

  infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
  name: 'Leaves of Grass by Walt Whitman.epub',
  private: false,
  created: new Date('Thu Aug 01 2013 06:27:46 GMT-0700 (PDT)'),
  announce: [
  files: [
      path: 'Leaves of Grass by Walt Whitman.epub',
      name: 'Leaves of Grass by Walt Whitman.epub',
      length: 362017,
      offset: 0
  length: 362017,
  pieceLength: 16384,
  lastPieceLength: 1569,
  pieces: [

For convenience, read-torrent also support reading magnet uri. Resulting information is limited, though.

// "Leaves of Grass" by Walt Whitman 
var uri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&'
readTorrent(uri, function(err, torrent) {
  // we loaded a torrent from a magnet uri 

Resulting information depends on the contents of the URI, but infoHash is guaranteed for any valid magnet uri.

Command-line interface

There is also a command-line interface available if you install it with -g

npm install -g read-torrent

This installs a program called read-torrent that you simply pass a torrent file or url


This will print all meta info of the torrent file to the terminal


Thanks to for parse-torrent and magnet-uri