Skip to content
uencoder

BSON Binary

BSON Binary is BSON's binary data type, storing arbitrary byte streams with a subtype marker (e.g., generic, UUID, MD5).

Purpose

To store binary data in MongoDB (images, encryption keys, raw UUID bytes) more compactly than a Base64 string.

Mechanism

BSON type 5 (binary): a 4-byte length plus a 1-byte subtype plus the raw bytes. Subtypes: 0=generic, 3=legacy UUID, 4=new UUID, 5=MD5, 128=user-defined.

Use cases

  • MongoDB binary storage
  • GridFS file chunks
  • Raw UUID byte storage

Related tools

References