Erlang BERT encoder/decoder
Latest commit 92e7e03 Jan 8, 2010 @mojombo release 1.1.0

Erlang BERT encoder/decoder. See for full spec.

Watch and contribute to this module at

This module is Semantic Versioning ( compliant.

The following types can be automatically encoded and decoded. See for type definitions.

integer() -> BERT integer float() -> BERT float atom() -> BERT atom tuple() -> BERT tuple list() -> BERT list or BERT bytelist string() -> BERT list or BERT bytelist (you probably want binary) binary() -> BERT binary [] -> BERT nil (complex) bool() -> BERT boolean (complex) dict() -> BERT dict (complex)

Because times and regular expressions types cannot be automatically detected, you must encode and decode those types manually.

To encode Erlang terms to BERT binaries, use:

encode(term()) -> binary().

To decode BERT binaries to Erlang terms, use:

decode(binary()) -> term().


% Encode a variety of literal Erlang terms:
bert:encode([42, 3.14, banana, {xy, 5, 10}, <<"robot">>, true, false]).
% -> <<131,108,0,0,0,7,97,42,99,51,46,49,52,48,48,48,48,48,48,...>>

% Encode an Erlang dict() record:
D0 = dict:new().
D1 = dict:store(apple, red, D0).
% -> <<131,104,9,100,0,4,100,105,99,116,97,0,97,16,97,16,97,8,...>>

% Decode a BERT binary:
% -> [42, 3.14, banana, {xy, 5, 10}, <<"robot">>, true, false]