跳到主要内容

Bencode 编码器/解码器

将 bencode(BitTorrent .torrent 文件使用的编码格式)解码为 JSON,或将 JSON 编码为 bencode — 解码 torrent 文件字典时提供 torrent 信息摘要。

输入

Drop a file or browse
One file · any type

输出

结果
Torrent 信息
属性
No data yet
这对您有帮助吗?

使用此工具的更多方式

REST API

curl -X POST https://api.iotools.cloud/v1/tool/bencode-encoder-decoder \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "decode",
    "inputText": "d8:announce35:http://tracker.example.com/announc…",
    "jsonInput": ""
  }'

替换成您账户中的密钥。工具的字段即为请求体——没有额外包装。

让 AI 代理执行

Use the IOTools `bencode-encoder-decoder` tool (Bencode Encoder/Decoder) on this input:

YOUR_INPUT_HERE

将此粘贴给任何已连接 IOTools MCP 服务器的代理,再加上您的输入内容。

嵌入式小组件

<iframe
  src="https://iotools.cloud/embed/bencode-encoder-decoder/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="Bencode 编码器/解码器 — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

把它放到您自己的页面上——免费,无需密钥,只需保留一个反向链接。

每次 API/MCP 调用费用5 积分起
需要更多积分?查看定价

也可通过

使用指南

什么是 bencode?

Bencode("B-encode")是 BitTorrent 使用的数据序列化格式 — 这是 .torrent 文件和跟踪器响应编码整数、字节串、列表和字典的方式。它比 JSON 更简单(没有空格、没有浮点数、字典键必须是字符串并且已排序),但用途相同:以紧凑、明确的方式表示结构化数据。

此工具如何工作

在两种模式之间切换:

  1. 解码 (Bencode → JSON) — 粘贴原始 bencode 文本(或上传 .torrent 文件)并获得可读的 JSON。不是有效 UTF-8 文本的二进制数据表示为带有 hex: 前缀的十六进制字符串,因为 JSON 无法保存原始字节。
  2. 编码 (JSON → Bencode) — 粘贴 JSON 并获得其 bencode 表示形式。字典键按字母顺序排序,符合规范的 bencode 编码规则。

如果解码的数据看起来像 torrent 文件(具有 announce URL、info 字典等),Torrent 信息表会总结跟踪器、名称、分片长度、文件列表和总大小。

Bencode 的四种类型

  • 整数: i42e42(任意大小 — 此工具在内部使用 BigInt,因此超大整数不会无声地失去精度,对于超过 Number.MAX_SAFE_INTEGER 的值回退到字符串)
  • 字节字符串: 5:hello"hello"(长度前缀,无引号)
  • 列表: l4:spam4:eggse["spam", "eggs"]
  • 字典: d3:cow3:mooe{"cow": "moo"}(键必须是字符串,编码时排序)

常见用途

  • 在没有 BitTorrent 客户端的情况下检查 .torrent 文件的内容
  • 调试生成或使用 bencode 的服务
  • 将结构化数据转换为 bencode 以用于 BitTorrent 相邻协议
  • 通过并排查看 JSON 来学习 bencode 格式

隐私

此工具完全在您的浏览器中运行。您的数据永远不会上传到服务器。

bencodetorrentbittorrentjsonencoderdecoder

喜欢这些工具?去掉广告吧。

一次性付款即可永久移除您账户中的所有广告。无需订阅,不追踪。