The Short Answer
BSON stands for Binary JSON. It's a way of storing JSON-style data — objects, arrays, and values — as compact binary that computers can read and jump through quickly. If you've used MongoDB, you've already used BSON without realizing it: it's the format MongoDB uses to store every document.
Quick definition: BSON = JSON's data model, encoded as binary, with a few extra data types and some speed tricks baked in. Think "JSON built for a database".
JSON is wonderful for humans — you can open a JSON file and read it straight away. But that readability comes at a cost: it's text, so a database has to scan through it character by character. BSON keeps JSON's friendly structure but swaps the text for binary, adds type information, and stores the length of each value so software can skip ahead instead of reading everything.
Why BSON Exists
JSON is great, but it has two gaps when you're running a database. BSON was designed to fill them:
Speed to Traverse
BSON stores a length prefix with each value, so a database can skip straight to the field it wants instead of parsing the whole document.
Richer Data Types
JSON only has strings, numbers, booleans, null, arrays, and objects. BSON adds dates, ObjectIds, binary data, and precise number types.
Built for Storage
The binary layout is designed to be efficient to store, index, and update — exactly what a document database needs.
In other words, BSON isn't trying to replace JSON everywhere. It's JSON's data model, tuned for the specific job of running a fast, queryable database.
The Extra Data Types
This is where BSON really pulls ahead of plain JSON. A few of the most useful types it adds:
| Type | What it's for |
|---|---|
| ObjectId | MongoDB's built-in unique ID for every document |
| Date | A real timestamp, instead of a date stuffed into a string |
| Binary | Raw bytes — images, files, hashes, and the like |
| Decimal128 | High-precision numbers for money and finance |
| Int32 / Int64 | Specific integer sizes, instead of JSON's single number type |
In JSON, you'd have to fake most of these — storing a date as a string, or an ID as text. BSON gives them proper types, which makes querying and sorting far more reliable.
A Quick Example
Here's a document the way you'd write it in JSON:
{
"name": "Alice",
"age": 30,
"joined": "2026-02-01T10:00:00Z",
"active": true
}When MongoDB stores it as BSON, the shape is the same, but each value gains a type tag and a length, and joined becomes a real Date rather than a string. Conceptually, MongoDB sees it more like this:
{
"_id": ObjectId("65b1f2c3a1d4e5f60718293a"),
"name": "Alice", // string
"age": 30, // int32
"joined": ISODate("2026-02-01T10:00:00Z"), // real date
"active": true // boolean
}Same data you'd recognize from JSON — just with proper types and a binary layout underneath. To see the round trip yourself, run some JSON through the JSON to BSON converter and back with BSON to JSON.
BSON vs JSON at a Glance
| Feature | BSON | JSON |
|---|---|---|
| Format | Binary | Text |
| Human Readable | No | Yes |
| Traversal Speed | Fast | Slower |
| Data Types | Many (Date, ObjectId…) | Basic |
| Best For | Databases (MongoDB) | APIs, config, sharing |
Want the full breakdown with code in Python and Node.js? Read the deeper BSON vs JSON comparison.
Do You Need to Write BSON Yourself?
Almost never — and that's good news. When you use MongoDB, you write plain JSON-like documents in your code, and the MongoDB drivers quietly convert them to and from BSON for you. You get BSON's speed and data types without ever hand-writing binary.
You'll mainly run into raw BSON in a couple of situations: exporting or inspecting database dumps, or working in Python with PyMongo. When you need to read a BSON dump, these tools make it painless:
Learn More
Official Resources
- BSON Specification
The official format spec
- MongoDB BSON Types
Every BSON data type, explained
- PyMongo Documentation
Working with BSON in Python
Related Guides
- BSON vs JSON
Full comparison with code examples
- pip install bson
Setting up BSON in Python
- What is JSON?
The format BSON is built on