1001Ferramentas
🔄Converters

BSON to JSON (text) Converter

Explains differences between binary BSON and JSON with a type table and textual conversion examples.

Cole os bytes BSON em hex. Binary/ObjectId viram 0x…; datetime vira ms. int64 pode perder precisão acima de 2⁵³.

BSON é o formato binário usado pelo MongoDB. Ele suporta tipos extras como ObjectId, Date, Binary e Decimal128.

Em JSON estendido (EJSON), esses tipos viram objetos:

{ "_id": { "$oid": "5f..." }, "ts": { "$date": "2024-01-01T00:00:00Z" } }

A conversão direta de bytes BSON exige bibliotecas (ex: bson do NPM).

Turning Mongo BSON bytes into readable JSON

You pulled a document out of MongoDB with mongodump, opened it in a hex editor and now you are staring at a wall of bytes. Or a binary blob showed up in a log and you need to know which fields live inside it before writing any code. Paste the hex into the top box and the document appears as indented JSON right below. Whitespace and a leading 0x are ignored.

The decoder reads the 32-bit length header, walks the type-name-value triples and stops at the trailing null byte. It handles double, string, embedded document, array, binary, ObjectId, boolean, UTC datetime, null, int32, timestamp and int64. Binary values and ObjectIds come back as text starting with 0x rather than the EJSON $oid form shown in the explainer. A datetime becomes a millisecond number such as 1715253010752, never an ISO string.

Anything outside that list stops the parse with a not-supported message and the type byte in hex: decimal128 (0x13), regular expressions (0x0b) and JavaScript code all land there. 64-bit integers above 2^53 arrive rounded, because the output goes through a JavaScript number. For whole files, or when those types matter, reach for the bson package on NPM. This page is for peeking at one small document fast, with nothing uploaded.

Frequently asked questions

Do I need to upload the .bson file?
No. You paste the bytes as hex and the decoding happens on the page itself, with no upload.
Why does the ObjectId show up with a 0x prefix?
That is how this tool renders binary values. Drop the prefix and you have the same 24 hex characters Mongo displays.
What if the document contains decimal128?
That type is not supported and the parse stops with an error. Convert the document with the bson library or with mongoexport in EJSON mode.

Related Tools