Skip to main content

Bencode Encoder/Decoder

Decode bencode (the encoding used by BitTorrent .torrent files) into JSON, or encode JSON into bencode — with a torrent-info summary when decoding a torrent file's dictionary.

Input

Drop a file or browse
One file · any type

Output

Result
Torrent Info
PropertyValue
No data yet
Was this helpful?

Guides

What is bencode?

Bencode ("B-encode") is the data serialization format used by BitTorrent — it's how .torrent files and tracker responses encode integers, byte strings, lists, and dictionaries. It's simpler than JSON (no whitespace, no floats, dictionary keys must be strings and are sorted) but serves the same purpose: a compact, unambiguous way to represent structured data.

How this tool works

Switch between two modes:

  1. Decode (Bencode → JSON) — paste raw bencode text (or upload a .torrent file) and get back readable JSON. Binary data that isn't valid UTF-8 text is represented as a hex:-prefixed hex string, since JSON can't hold raw bytes.
  2. Encode (JSON → Bencode) — paste JSON and get back its bencode representation. Dictionary keys are sorted alphabetically, matching the canonical bencode encoding rule.

If the decoded data looks like a torrent file (has an announce URL, an info dictionary, etc.), a Torrent Info table summarizes the tracker, name, piece length, file list, and total size.

Bencode's four types

  • Integers: i42e42 (arbitrarily large — this tool uses BigInt internally so oversized integers don't silently lose precision, falling back to a string for values beyond Number.MAX_SAFE_INTEGER)
  • Byte strings: 5:hello"hello" (length-prefixed, no quotes)
  • Lists: l4:spam4:eggse["spam", "eggs"]
  • Dictionaries: d3:cow3:mooe{"cow": "moo"} (keys must be strings, sorted when encoding)

Common uses

  • Inspecting the contents of a .torrent file without a BitTorrent client
  • Debugging a bencode-producing or bencode-consuming service
  • Converting structured data to bencode for a BitTorrent-adjacent protocol
  • Learning the bencode format by seeing it side-by-side with JSON

Privacy

This tool runs entirely in your browser. Your data is never uploaded to a server.

bencodetorrentbittorrentjsonencoderdecoder

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.