🍋
Menu
.bson Data

BSON (Binary JSON)

BSON is the binary serialization format used by MongoDB to store documents. It extends JSON with additional data types (dates, binary, ObjectId, decimal128) and is designed for efficient encoding, scanning, and in-place updates within a document database.

MIME Type

application/bson

Type

Binary

Compression

Lossless

Advantages

  • + Rich type system beyond JSON (dates, ObjectId, binary, Decimal128)
  • + Efficient for database storage — length-prefixed for fast scanning
  • + Supports in-place updates without rewriting entire documents

Disadvantages

  • Can be larger than JSON for string-heavy documents
  • Not human-readable — requires tooling to inspect
  • Primarily MongoDB-specific — limited use outside that ecosystem

When to Use .BSON

BSON is primarily used internally by MongoDB; for data exchange, prefer JSON or MessagePack.

Technical Details

BSON documents are length-prefixed binary with type-tagged elements. Each element has a one-byte type identifier, a C-string key, and a type-specific value. This enables O(1) size checking and efficient traversal.

History

MongoDB Inc. (then 10gen) developed BSON in 2009 as the internal storage and wire format for MongoDB. The specification is open and has been adopted by other projects needing a typed JSON-like binary format.

Convert from .BSON

Convert to .BSON

Related Formats