BSON Data Format — MongoDB Technical Interview Questions & Answers
The binary JSON format MongoDB stores documents in.
BSON Data Format
- Simple meaning: BSON is Binary JSON — the format MongoDB stores and sends. You still type JSON-looking objects in mongosh.
- Why binary: types like Date, ObjectId, BinData, and slightly faster for the server. JSON is text; BSON is the on-disk form.
- Try this: db.students.findOne() and look at _id — that ObjectId is a BSON type, not a plain string in storage.
- Common mistake: saying “Mongo stores JSON files on disk”. It stores BSON.
- Interview tip: “JSON-like documents, BSON on disk/wire. ObjectId is a BSON type.”
Technical Interview Tip: JSON-like for humans, BSON for MongoDB.
Code Examples for BSON Data Format
BSON Data Format — working example
// Collection "users" holds BSON documents (JSON-like):
db.users.insertOne({
name: "Ada",
email: "ada@example.com",
age: 36,
skills: ["Java", "MongoDB"],
address: { city: "Pune", pin: "411001" }
})
db.users.find({ "address.city": "Pune" })BSON Data Format — mongoDB stores BSON documents in collections — flexible schema, nested fields, rich queries.
How to Explain BSON Data Format to an Interviewer
What is BSON?
Binary JSON MongoDB uses to store documents Supports ObjectId and Date