Double | 64-bit IEEE 754 floating-point value | 8 bytes | Used for storing floating-point numbers. |
String | UTF-8 encoded string | Variable (length-prefixed) | Used to store textual data. |
Object | Embedded document (similar to a JSON object) | Variable (length-prefixed) | Stores nested documents. |
Array | List of values (can be other BSON types) | Variable (length-prefixed) | Stores ordered collections of values. |
Binary Data | Arbitrary binary data (used for storing files, images, etc.) | Variable (length-prefixed) | Used to store binary objects (e.g., images). |
Undefined | Used in earlier versions of BSON, now deprecated | 1 byte | Deprecated in modern BSON. |
ObjectId | 12-byte identifier that uniquely identifies a document in MongoDB | 12 bytes | Used as a unique identifier for documents. |
Boolean | Boolean value (true or false ) | 1 byte | Used for logical values. |
Date | 64-bit integer representing a Unix timestamp in milliseconds | 8 bytes | Used for storing date/time values. |
Null | Null value | 1 byte | Used to represent a missing or empty value. |
Regular Expression | Regular expression pattern | Variable (length-prefixed) | Used for storing regular expressions. |
DBPointer | Pointer to a document in another collection (deprecated in favor of DBRefs) | Variable (length-prefixed) | Deprecated. Previously used for cross-collection references. |
JavaScript | JavaScript code (with scope) | Variable (length-prefixed) | Stores JavaScript code. |
Symbol | Deprecated data type for storing symbols | Variable (length-prefixed) | Deprecated, previously used for symbols. |
Decimal128 | 128-bit decimal representation for high precision (used in financial data) | 16 bytes | Used for storing high-precision decimal values. |
MinKey | Special value used for comparison; less than all other values | 1 byte | Used in queries to represent the lowest possible value. |
MaxKey | Special value used for comparison; greater than all other values | 1 byte | Used in queries to represent the highest possible value. |