{"id":13482059,"url":"https://github.com/webtorrent/create-torrent","last_synced_at":"2025-12-15T15:58:35.279Z","repository":{"id":17245375,"uuid":"20014609","full_name":"webtorrent/create-torrent","owner":"webtorrent","description":"Create .torrent files","archived":false,"fork":false,"pushed_at":"2024-05-11T22:03:51.000Z","size":1013,"stargazers_count":340,"open_issues_count":6,"forks_count":92,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-05-22T18:12:45.120Z","etag":null,"topics":["bittorrent","browser","create","javascript","nodejs","torrent","torrent-files","webtorrent"],"latest_commit_sha":null,"homepage":"https://webtorrent.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webtorrent.png","metadata":{"funding":{"github":["webtorrent","feross"]},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-21T08:53:36.000Z","updated_at":"2024-06-02T02:22:32.233Z","dependencies_parsed_at":"2023-02-17T01:46:32.146Z","dependency_job_id":"78e9ff36-3a73-47fe-b4fe-fab88735432f","html_url":"https://github.com/webtorrent/create-torrent","commit_stats":{"total_commits":517,"total_committers":32,"mean_commits":16.15625,"dds":"0.36557059961315286","last_synced_commit":"0276af91d4134c731f08773aa5bdc221268ee4f7"},"previous_names":[],"tags_count":138,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Fcreate-torrent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Fcreate-torrent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Fcreate-torrent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Fcreate-torrent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webtorrent","download_url":"https://codeload.github.com/webtorrent/create-torrent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245845155,"owners_count":20681850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bittorrent","browser","create","javascript","nodejs","torrent","torrent-files","webtorrent"],"created_at":"2024-07-31T17:00:58.615Z","updated_at":"2025-12-15T15:58:35.168Z","avatar_url":"https://github.com/webtorrent.png","language":"JavaScript","readme":"# create-torrent [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[ci-image]: https://github.com/webtorrent/create-torrent/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/webtorrent/create-torrent/actions/workflows/ci.yml\n[npm-image]: https://img.shields.io/npm/v/create-torrent.svg\n[npm-url]: https://npmjs.org/package/create-torrent\n[downloads-image]: https://img.shields.io/npm/dm/create-torrent.svg\n[downloads-url]: https://npmjs.org/package/create-torrent\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n#### Create .torrent files\n\n![creation](https://raw.githubusercontent.com/webtorrent/create-torrent/master/img.jpg)\n\nThis module is used by [WebTorrent](http://webtorrent.io)! This module works in node.js and the browser (with [browserify](http://browserify.org/)).\n\n### install\n\n```\nnpm install create-torrent\n```\n\n### usage\n\nThe simplest way to use `create-torrent` is like this:\n\n```js\nimport createTorrent from 'create-torrent'\nimport fs from 'fs'\n\ncreateTorrent('/path/to/folder', (err, torrent) =\u003e {\n  if (!err) {\n    // `torrent` is a Buffer with the contents of the new .torrent file\n    fs.writeFile('my.torrent', torrent)\n  }\n})\n```\n\nA reasonable piece length (approx. 1024 pieces) will automatically be selected\nfor the .torrent file, or you can override it if you want a different size (See\nAPI docs below).\n\n### api\n\n#### `createTorrent(input, [opts], function callback (err, torrent) {})`\n\nCreate a new `.torrent` file.\n\n`input` can be any of the following:\n\n- path to the file or folder on filesystem (string)\n- W3C [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object (from an `\u003cinput\u003e` or drag and drop)\n- W3C [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList) object (basically an array of `File` objects)\n- Node [Buffer](http://nodejs.org/api/buffer.html) object\n- Node [stream.Readable](http://nodejs.org/api/stream.html) object\n\nOr, an **array of `string`, `File`, `Buffer`, or `stream.Readable` objects**.\n\n`opts` is optional and allows you to set special settings on the produced .torrent file.\n\n``` js\n{\n  name: String,             // name of the torrent (default = basename of `path`, or 1st file's name)\n  comment: String,          // free-form textual comments of the author\n  createdBy: String,        // name and version of program used to create torrent\n  creationDate: Date        // creation time in UNIX epoch format (default = now)\n  filterJunkFiles: Boolean, // remove hidden and other junk files? (default = true)\n  private: Boolean,         // is this a private .torrent? (default = false)\n  pieceLength: Number,      // force a custom piece length (number of bytes)\n  maxPieceLength: Number,   // force a maximum piece length for auto piece length selection, does not affect pieceLength option (default = 4 MiB)\n  announceList: [[String]], // custom trackers (array of arrays of strings) (see [bep12](http://www.bittorrent.org/beps/bep_0012.html))\n  urlList: [String],        // web seed urls (see [bep19](http://www.bittorrent.org/beps/bep_0019.html))\n  info: Object,             // add non-standard info dict entries, e.g. info.source, a convention for cross-seeding\n  onProgress: Function      // called with the number of bytes hashed and estimated total size after every piece\n}\n```\n\nIf `announceList` is omitted, the following trackers will be included automatically:\n\n- udp://tracker.leechers-paradise.org:6969\n- udp://tracker.coppersurfer.tk:6969\n- udp://tracker.opentrackr.org:1337\n- udp://explodie.org:6969\n- udp://tracker.empire-js.us:1337\n- wss://tracker.btorrent.xyz\n- wss://tracker.openwebtorrent.com\n- wss://tracker.webtorrent.dev\n\nTrackers that start with `wss://` are for WebRTC peers. See\n[WebTorrent](https://webtorrent.io) to learn more.\n\n`callback` is called with an error and a Buffer of the torrent data. It is up to you to\nsave it to a file if that's what you want to do.\n\n**Note:** Every torrent is required to have a name. If one is not explicitly provided\nthrough `opts.name`, one will be determined automatically using the following logic:\n\n- If all files share a common path prefix, that will be used. For example, if all file\n  paths start with `/imgs/` the torrent name will be `imgs`.\n- Otherwise, the first file that has a name will determine the torrent name. For example,\n  if the first file is `/foo/bar/baz.txt`, the torrent name will be `baz.txt`.\n- If no files have names (say that all files are Buffer or Stream objects), then a name\n  like \"Unnamed Torrent \u003cid\u003e\" will be generated.\n\n**Note:** Every file is required to have a name. For filesystem paths or W3C File objects,\nthe name is included in the object. For Buffer or Readable stream types, a `name` property\ncan be set on the object, like this:\n\n```js\nconst buf = Buffer.from('Some file content')\nbuf.name = 'Some file name'\n```\n\n### command line\n\n```\nusage: create-torrent \u003cdirectory OR file\u003e {-o outfile.torrent}\n\nCreate a torrent file from a directory or file.\n\nIf an output file isn\\'t specified with `-o`, the torrent file will be\nwritten to stdout.\n```\n\n### license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io).\n","funding_links":["https://github.com/sponsors/webtorrent","https://github.com/sponsors/feross"],"categories":["Modules","Libraries"],"sub_categories":["Javascript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebtorrent%2Fcreate-torrent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebtorrent%2Fcreate-torrent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebtorrent%2Fcreate-torrent/lists"}