Overview
Introduction
Bencode is what every .torrent file is written in, and it hasn't changed since the original BitTorrent spec, but its length-prefixed byte strings and i...e integers aren't something most JSON-based tooling can read directly.
This tool decodes Bencode text into JSON so a .torrent file's metadata or a tracker response can be inspected and processed with ordinary JSON tools.
What Is Bencode to JSON Converter?
A Bencode decoder that reads the format's four primitives, length-prefixed byte strings, i...e integers, l...e lists, and d...e dictionaries, and reconstructs the equivalent JSON value.
Dictionaries become JSON objects and lists become JSON arrays, a direct structural mapping since both formats share the same fundamental container shapes.
How Bencode to JSON Converter Works
The decoder reads the Bencode text left to right, dispatching on the next character: a digit starts a length-prefixed string, i starts an integer, l starts a list, and d starts a dictionary, recursing into nested values as needed.
Each primitive is self-delimiting (a string's length prefix says exactly how many bytes follow; i, l, and d values end with a matching e), so the decoder always knows exactly where one value ends and the next begins without needing separators.
When To Use Bencode to JSON Converter
Use it when inspecting a .torrent file's metadata (its info dictionary, announce URL, piece list) and you want it as readable JSON rather than raw Bencode text.
It's also useful for decoding a BitTorrent tracker's Bencode-encoded response for debugging a client or tracker implementation.
Often used alongside JSON to Bencode Converter, BSON to JSON Converter and UBJSON to JSON Converter.
Features
Advantages
- Handles arbitrarily nested lists and dictionaries, matching real .torrent file structures.
- Reports a specific parse error location for malformed Bencode instead of failing silently.
- Runs entirely client-side, so torrent metadata never leaves the browser.
Limitations
- Byte strings are decoded as UTF-8 text, so a byte string containing genuinely non-UTF-8 binary data (such as raw piece hash bytes) won't be represented as readable text.
- There's no distinction preserved between a Bencode integer and how it might be used semantically (e.g. as a boolean flag), it always becomes a plain JSON number.
Examples
Best Practices & Notes
Best Practices
- Paste Bencode text exactly as captured, extra whitespace or line breaks inside a length-prefixed string will corrupt the length count.
- When decoding a real .torrent file, expect the pieces field (raw SHA-1 hash bytes) to not render as meaningful text, that's expected given its binary content.
- Use this to spot-check a hand-written Bencode encoder's output against the expected JSON structure.
Developer Notes
The decoder tracks a single read cursor through the input string and advances it by exactly the number of characters each primitive consumes, computed from each string's explicit length prefix, rather than scanning for delimiters, which is what lets it correctly handle byte strings that happen to contain characters like e or : inside their content.
Bencode to JSON Converter Use Cases
- Inspecting a .torrent file's info dictionary and metadata as readable JSON
- Decoding a BitTorrent tracker's Bencode response while debugging a client
- Verifying a custom Bencode encoder's output round-trips to the expected JSON
Common Mistakes
- Pasting a .torrent file's raw binary bytes instead of its Bencode text representation.
- Expecting binary fields like the pieces hash list to decode into readable text.
- Editing a length-prefixed string by hand without updating its length prefix, which desynchronizes the rest of the parse.
Tips
- Use JSON to Bencode afterward to confirm the decoding round-trips the way you expect.
- If a large .torrent file fails to decode, isolate a single dictionary key's value first to narrow down which field is malformed.