Skip to content
ufraan
← Back

Bencode Foo

Tiny Go bencode decoder with recursive parsing.

GoImage ProcessingParser
Mar 2026GitHubLive

A minimal bencode decoder in Go, built as a hands-on exploration of the encoding format used by BitTorrent for torrent files. It parses bencoded data into native Go types — strings, integers, lists, and dictionaries — handling all four bencode types with their respective delimiters. All string handling is binary-safe.

Bencode Foo parser output showing decoded torrent data
Bencode Foo parser output showing decoded torrent data

The parser uses a manual cursor approach, reading byte-by-byte and dispatching to recursive parsing functions based on the type prefix. This keeps the implementation small and easy to follow with no external libraries.