MongoDB โ€” JSON vs BSON Deep Dive

๐Ÿƒ MongoDB 7.0+ ๐ŸŸข Chapter 9 of 50 ๐Ÿ“‚ Phase 02: Databases, Collections & BSON Documents ๐Ÿ“… 2026 Edition

Compare human-readable JSON against binary BSON. Learn about Extended JSON (EJSON) formats and how MongoDB driver serialization works.

1Side-by-Side Comparison: JSON vs BSON
FeatureJSON (JavaScript Object Notation)BSON (Binary JSON)
FormatText-based string formatBinary encoded bytes
ReadabilityHuman-readableMachine-readable (requires parser)
Data TypesString, Number, Boolean, Array, Object, Null20+ Data types (Date, ObjectId, Decimal128, BinData)
Traversal SpeedSlow (must parse entire text string)Fast (contains length prefixes & index offsets)
Storage EfficiencySpace inefficient for large numbers/datesHighly optimized for disk and memory RAM
2MongoDB Extended JSON (EJSON)

When converting BSON data to standard JSON for REST APIs, special BSON types are serialized using MongoDB Extended JSON (EJSON) specification:

Canonical EJSON Example
{
  "_id": { "$oid": "65d8f1e2a9b3c4d5e6f7a8b9" },
  "createdAt": { "$date": "2026-08-26T12:00:00Z" },
  "price": { "$numberDecimal": "99.95" }
}
OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on MongoDB 7.0+ Standards ยท Last updated August 2026