What is a .bson file?
Binary JSON · Data · MongoDB · 2009
BSON is a binary form of JSON used by MongoDB to store documents. It encodes the same field-and-value structure as JSON but in binary, adding data types JSON lacks, such as dates and raw binary.
What is a .bson file used for?
A BSON document begins with a 4-byte little-endian length rather than a fixed magic number, then its typed fields. It trades JSON's readability for faster parsing and richer types, which is why databases use it internally.
You rarely handle .bson files by hand; they come from MongoDB dumps (mongodump). Restore them with mongorestore, or read them with a BSON library.
What opens a .bson file?
The .bson format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.
Windows
- MongoDB tools (mongorestore)
- Python (bson)
- MongoDB Compass
macOS
- MongoDB tools
- Python (bson)
- MongoDB Compass
Linux
- MongoDB tools
- Python (bson)
Open a .bson file step by step
- Confirm the file really is a .bson. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with MongoDB tools (mongorestore) or Python (bson).
- On Mac, use MongoDB tools or Python (bson).
- On Linux, try MongoDB tools or Python (bson).
- Still stuck? Convert the .bson to json, which opens more widely.
Why can't I open my .bson file?
Almost always because no installed app understands BSON. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .bson at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
How to convert a .bson file
You can convert a .bson file to json using a conversion tool or the export menu of an app that opens it.
BSON has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
Frequently asked questions
What is a .bson file?
BSON is a binary form of JSON used by MongoDB to store documents. It encodes the same field-and-value structure as JSON but in binary, adding data types JSON lacks, such as dates and raw binary.
What is the difference between BSON and JSON?
BSON is binary and adds types JSON lacks (dates, binary, precise numbers) for faster machine reading. JSON is text and human-readable. MongoDB stores BSON internally.
How do I open a .bson file?
It usually comes from a MongoDB dump. Restore it with mongorestore, or read it with a BSON library such as Python's bson module.
Can I convert BSON to JSON?
Yes. MongoDB's bsondump tool, or a BSON library, converts a .bson document into readable JSON.
Related formats
Sources
Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.