MongoDB Tutorial 0/120 lessons ~6 min read Lesson 17
JSON vs BSON
JSON is the universal data interchange format of the web.
Course progress0%
Focus
5 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
JSON is the universal data interchange format of the web. BSON is its binary cousin, optimized for storage and traversal. MongoDB drivers transparently convert between JSON in your code and BSON on the wire — but the differences matter when you debug, serialize, or migrate data.
Understanding the topic
Key differences:
- JSON — text, human-readable, type-poor (everything number is a float).
- BSON — binary, fast to parse, type-rich (int32, int64, decimal, date, binary).
- JSON can't represent dates or binary natively — BSON can.
- BSON is length-prefixed: the server can skip fields without parsing them.
- Drivers convert automatically — you almost always write JSON-like syntax.
Syntax reference
js
// JSON{ "createdAt": "2026-06-08T12:00:00Z", "price": 9.99 }// BSON (logically){ createdAt: ISODate("2026-06-08T12:00:00Z"),price: NumberDecimal("9.99") }
Real-world use
Export your data with mongoexport — you get Extended JSON, a textual encoding of BSON that preserves all the type info.
Best practices
- Use Extended JSON for backups + migrations.
- Don't round-trip BSON through plain JSON — you'll lose types.
Ready to mark this lesson complete?Track your journey across the entire course.