JSON to BSON
Paste or drop your data here, or open a file.
New to Bracely?
Everything stays in your browser.
Output appears here
Paste or open your data in the input box. It never leaves your browser.
JSON to BSON
BSON is the binary format MongoDB stores and sends. Paste JSON, or Extended JSON with {"$oid": …} and {"$date": …}, and get the exact BSON bytes as Base64 or hex, or save them as a .bson file.
Example: a MongoDB document with an ObjectId, a date and a big number
Extended JSON, as mongosh and Compass export it. The ObjectId, the date and the 64-bit count become their BSON types, not strings, so the bytes are what MongoDB itself would store. Here as hex, so the type bytes are visible:
Input
{
"_id": {
"$oid": "6530f1a2b4c5d6e7f8091a2b"
},
"placedAt": {
"$date": "2026-10-29T10:00:00Z"
},
"views": {
"$numberLong": "9007199254740993"
}
}Output
37000000075f6964006530f1a2b4c5d6e7f8091a2b09706c6163656441740000251a87a101000012766965777300010000000000200000
How do I use the JSON to BSON?
- Paste JSON or Extended JSON, such as a document from mongosh or Compass.
- Pick Base64 or hex output.
- Copy the bytes, or press Save for a .bson file.
What does the JSON to BSON do?
- ObjectId, dates, Decimal128 and 64-bit numbers from Extended JSON
- Base64 or hex output, or a .bson file
- Reads back with BSON to JSON to check the round trip
When to use the JSON to BSON
MongoDB stores and sends documents as BSON, a binary format with types JSON doesn't have: ObjectId, dates, 64-bit integers, Decimal128 and binary data. Turning JSON into BSON is useful when you write test fixtures for a driver, check what a document looks like on the wire, or build a .bson file for mongorestore.
Plain JSON works, and Extended JSON, as mongosh, Compass and mongoexport write it, keeps the types: {"$oid": …} becomes an ObjectId, {"$date": …} a date, {"$numberLong": …} a 64-bit integer and {"$numberDecimal": …} a Decimal128, all written exactly. Output is Base64 or hex, or Save gives a .bson file. Reading the bytes back with BSON to JSON gives the same Extended JSON, which is a quick way to check a round trip.
Frequently asked questions
- Why does my date come out as a string?
- In plain JSON a date is just text. Write it as Extended JSON, {"$date": "2026-10-29T10:00:00Z"}, and it becomes a BSON date; the same goes for {"$oid": …} and ObjectIds.
- Can I load the file with mongorestore?
- mongorestore reads .bson files of documents one after another, which is what Save writes for an array of documents. Check it on a test database first; mongoimport is simpler for plain JSON.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has 104 JSON tools in one page. Related ones:
- JSON to MessagePack
- Query string to JSON
- JSON to .env
- Excel to JSON
- JSON to YAML
- JSON to CSV
- JSON to XML
- JSON to Excel
- YAML to JSON
- CSV to JSON
- XML to JSON
- JSON to TOML
- TOML to JSON
- JSON Lines / NDJSON
- JSON to Scala
- JSON to Ruby
- Unflatten JSON
- Merge JSON
- JSON Formatter
- JSON Validator
- JSON Viewer
- JSON Repair
- JSON Diff
- jq Playground
Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram