Bencode to XML Converter

Decodes a Bencode string, dictionaries, lists, byte strings, and integers, into a plain value, then converts that into XML, useful for inspecting Bencoded data (like parts of a .torrent file) in a familiar format. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-23

Overview

Introduction

Bencoded data, from a .torrent file's info dictionary, for instance, isn't easy to read directly.

This tool decodes it into familiar XML.

What Is Bencode to XML Converter?

A decoder that parses Bencode's four types, strings, integers, lists, dictionaries, into a plain JS value.

It then converts that value into XML the same way the JSON to XML Converter does it.

How Bencode to XML Converter Works

The Bencode string is parsed character by character according to its type prefix (a digit for a length-prefixed string, i for an integer, l for a list, d for a dictionary), producing a plain value.

That value is then serialized as XML.

When To Use Bencode to XML Converter

Use it to inspect Bencoded data, like a .torrent file's dictionary structure, in a more familiar, readable format.

It's also useful for debugging BitTorrent-adjacent tooling output or verifying an XML to Bencode Converter round trip.

Features

Advantages

  • Implements the full Bencode specification, not a simplified subset.
  • Reports the exact position of a syntax error.
  • Runs entirely client-side.

Limitations

  • Very large Bencoded byte strings (like an actual .torrent file's piece hashes) will produce very long text nodes in the output; this tool isn't optimized for parsing multi-megabyte binary payloads.
  • A top-level Bencode list or scalar is wrapped under a generic 'item' key, since XML needs a single named root.

Examples

Decoding a dictionary

Input

d4:name3:Ada3:agei36ee

Output

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <name>Ada</name>
  <age>36</age>
</root>

Each dictionary key becomes an XML element.

Best Practices & Notes

Best Practices

  • Use XML to Bencode Converter alongside this one if you want to check what a round trip does to your specific data.
  • Paste the exact Bencode bytes as text, don't add or remove whitespace, it isn't part of the format but stray characters can still break parsing if inserted mid-string.
  • Check the reported character position first when decoding fails, it points directly at the problem.

Developer Notes

Decoding lives in `bencode-core.ts`'s `decodeBencode`, a hand-written recursive-descent parser with no external Bencode library dependency.

Bencode to XML Converter Use Cases

  • Inspecting a Bencoded value (like a .torrent info dictionary) in readable XML
  • Debugging BitTorrent-adjacent tooling output
  • Verifying an XML to Bencode Converter round trip

Common Mistakes

  • Pasting truncated or non-Bencode text and expecting a partial result, malformed input reports an error instead of a best-effort guess.
  • Assuming byte strings are always human-readable text, some Bencoded fields carry raw binary data.

Tips

  • Use XML to Bencode Converter to encode data back the other direction.
  • Check the FAQ above if the output doesn't look like what you expected.

References

Frequently Asked Questions