MediumExperience level: 3-5 years · 8-15 years2 min read

JSON vs BSON — Interview Questions

Reviewed by Gurusankar M.

Asked inAmazonMicrosoftDeloitteCognizant
#json#bson#mongodb#binary#serialization
Report issue

Short Answer

JSON is a text format; BSON (Binary JSON) is a binary encoding used by MongoDB. BSON adds types JSON lacks (ObjectId, native Date, binary data, Decimal128) and stores length prefixes so fields can be traversed/skipped fast. BSON is often larger than the equivalent JSON text but is quicker to parse and richer in types — you write JSON, MongoDB stores BSON.

On this page

Concept Made Simple

Coffee Chat Question

“What is the difference between JSON and BSON?”

Remember It Faster

Mind Map Answer

JSON
text, human-readable, 6 types
BSON
binary, extra types, length-prefixed
Extra types
ObjectId, Date, binary, Decimal128
Trade-off
BSON: fast traverse, sometimes bigger

Learn by Doing

Hands-on Keyboard

javascript
// You write JSON-like documents...
db.users.insertOne({
  name: "Guru",
  createdAt: new Date(),          // stored as BSON Date
});
// ...MongoDB stores them as BSON: _id becomes an ObjectId,
// the date is a native BSON Date (not an ISO string).

Think Beyond the Expected

What If?

If BSON can be larger than JSON, why does MongoDB use it?

Speed and richer types. BSON's length prefixes let the engine skip over fields without scanning byte-by-byte (fast indexing/traversal), and native types like Date, ObjectId, and Decimal128 avoid the lossy 'everything is a string/float' problem of JSON. The modest size overhead buys performance and type fidelity at the database layer.

Real World

MongoDB is the everyday example: the driver accepts JSON-like objects and stores BSON, which is why _id is an ObjectId and dates come back as real Date types rather than strings — a common surprise for developers new to Mongo.

Interviewer's Expectation

Keywords they're listening for:

  • JSON text vs BSON binary
  • BSON extra types (ObjectId/Date/binary/Decimal128)
  • length-prefixed → fast traverse
  • BSON can be larger
  • MongoDB storage format

Common Mistakes

  • Assuming BSON is always smaller than JSON
  • Thinking JSON has a native date/ObjectId type
  • Confusing the wire format with the storage format

Best Practices

  • Use JSON for interchange, let the DB use BSON
  • Rely on native BSON types instead of stringly-typed data
  • Consider protobuf/Avro for compact service-to-service traffic

Follow-up Questions

  1. Which types does BSON add over JSON?
  2. Why can BSON be larger yet faster?
  3. How does this compare to protobuf/Avro?

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Advanced (JSON)
Interview question: "What is the difference between JSON and BSON?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.