MongoDB โ€” Documents & BSON Data Types

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

Understand the BSON specification, document structures, array fields, embedded sub-documents, and the 16 MB document size limit.

1What is BSON?

While developers write queries using JSON syntax, MongoDB stores documents internally as BSON (Binary JSON). BSON was designed to achieve three key benefits: fast serialisation/deserialisation, compact binary storage, and support for rich data types missing in standard JSON.

2Complete BSON Data Types Reference
BSON TypeType NumberDescription & Example
String2UTF-8 encoded string: "Hello World"
Integer (32-bit)16Standard integer: NumberInt(42)
Long (64-bit)1864-bit integer for large counts: NumberLong(9007199254740991)
Decimal12819High-precision decimal for currency: NumberDecimal("99.95")
Double164-bit IEEE 754 floating point number: 3.14159
Boolean8true or false
Date964-bit UTC timestamp: ISODate("2026-08-26T12:00:00Z")
ObjectId712-byte primary key identifier: ObjectId("...")
Array4Ordered list of elements: ["apple", "banana"]
Object3Embedded sub-document: { city: "Hyderabad" }
Null10Null or missing value: null
Binary Data5Raw binary blobs (UUIDs, images): BinData(...)
3The 16 MB Document Size Limit

In MongoDB, a single BSON document cannot exceed 16 Megabytes in size. This design limit serves two critical purposes:

  • Prevents developers from creating massive unbounded documents that saturate network RAM.
  • Ensures fast memory lookup times in WiredTiger cache.
โš ๏ธ Schema Tip:

If you need to store files larger than 16 MB (such as videos or PDFs), use GridFS instead of embedding raw binary data directly into documents!

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on MongoDB 7.0+ Standards ยท Last updated August 2026