MongoDB Fundamentals
JSON vs BSON
Why MongoDB stores BSON, which types JSON cannot represent, and why that matters.
You write documents that look like JSON. MongoDB stores them as BSON — Binary JSON. Same shape, extra types, a binary layout the server can walk quickly.
{
"name": "Rahul",
"age": 28,
"createdAt": "2026-08-20T00:00:00.000Z"
}{
_id: ObjectId("64a1b2c3d4e5f6a7b8c90001"),
name: "Rahul",
age: 28,
createdAt: ISODate("2026-08-20T00:00:00.000Z")
}Why BSON exists
JSON cannot represent an ObjectId, a real Date, or a decimal that does not round like a float. Everything would become a string or a Double, and you would parse it back in application code. BSON keeps those types. It is also length-prefixed, so the server can skip a field without parsing the rest of the document.
You almost never look at the bytes. Drivers and the shell show you JSON-like objects. The important part is the types: Date stays a Date, ObjectId stays an ObjectId, Decimal128 stays exact.
- Date —
ISODate(...), not a string you have to parse on every query. - ObjectId — the default
_id. Next lesson. - Decimal128 — exact decimals for money. Covered with the other types.
- Int32 / Int64 / Double — JSON has one number type; BSON does not.
- Binary — raw bytes when you actually need them. Rare in API code.
Interview question
Why does MongoDB use BSON instead of JSON?
BSON adds types JSON does not have — ObjectId, Date, Decimal128, distinct integer and float types — and it is length-prefixed so the server can skip fields. Developers still think in JSON-like documents; the extra types are what you actually query.
Mentioning Decimal128 for money is a strong signal.