How to use it
- Choose a .bson file, or paste the BSON as Base64 or hex.
- Read the JSON; a file with several documents gives an array.
- “Reverse the direction” turns JSON into BSON.
Rules and limits
How BSON is read and written
- Reversing the direction writes an object as one document, or an array of objects as documents in a row, as mongodump does.
- A whole number larger than a 64-bit integer is refused instead of being changed, and Decimal128 values keep all 34 digits.
- Damaged data is reported with the byte where a length or a value does not fit.
Limits
- The text box shows the first 200,000 characters; the download has everything.
Questions and answers
How are MongoDB types written?
As in MongoDB Extended JSON: {"$oid": …} for ObjectId, {"$date": …} for dates, {"$numberDecimal": …}, {"$binary": …}, {"$timestamp": …}. 64-bit integers beyond 2^53 are written as {"$numberLong": …} so that no digit is lost.
Can it read a mongodump file?
Yes: the documents of a .bson file come one after another, and the result is an array of them. Very large dumps can be slow in a browser.
What if the data is cut off?
BSON begins with the length of each document, so a missing end is found at once and the message names the byte. Copy the whole value, for example the full hex dump.