Home > Specs > BitTorrent
BEncode
This is a binary format for storing maps, lists, string, and integers.
Integers
Integers are represented by the letter
i, followed by the number in text format, followed by the letter
e. The number may have a leading minus sign. Only characters 0-9 are allowed.
Example:
i1234e
Strings
Strings are represented by the the string length in text format, followed by a colon
:, followed by the string.
Example:
11:Hello World
Lists
Lists are represented by the letter
l, followed by nested maps, lists, strings, or integers, followed by the letter
e.
Examples:
li1234e11:Hello Worlde A list containing an integer and a string
le An empty list
Maps
Maps are represented by the letter
d, followed by key/value pairs, followed by the letter
e.
Examples:
d7:message11:Hello Worlde A map containing a key "message" with the value "hello world"
d1:xi50e1:yi100ee A map containing some coordinates
d4:billd3:agei42e6:heighti180ee3:tomd3:agei88e6:heighti170eee Nested maps
de An empty map