JSON ↔ BSON

Client

Encode a JSON object into BSON bytes (shown as Base64), or decode Base64 BSON back to pretty JSON—same panel pattern as MessagePack/CBOR, using the bson library in your tab.

For the 24 hex ObjectId layout (time and random bytes), use the dedicated ObjectId tool alongside this encoder.

Learn more: BSON

Encode a JSON object into MongoDB-style BSON bytes (Base64) or decode BSON back to JSON—same Base64 panel pattern as MessagePack/CBOR, but BSON is a single-document wire format with extended types.

Root must be an object

BSON documents are maps; encode a wrapper object if your payload is a bare array. Drivers may represent ObjectId, Decimal128, and other BSON-only types—this preview shows JSON-friendly values after decode.

Compared to MessagePack

Both are binary; BSON is common around MongoDB APIs. Prefer MessagePack/CBOR when you do not need BSON-specific types.

JSON & BSON

?

JSON → BSON uses JSON.parse then the bson serializer. BSON → JSON deserializes bytes and pretty-prints (dates become ISO strings in the preview).

BSON supports extra types (ObjectId, Decimal128, etc.) that round-trip through this preview as plain JSON values—verify against your driver when you need exact types.

Encode JSON to MongoDB-style BSON bytes, or decode Base64 BSON back to JSON. Root value must be an object.

Nearby workflows on Toolcore

  • JSON formatterwhen the document must parse before any transform or export.
  • MongoDB ObjectIdwhen BSON payloads include 24-hex ObjectId fields.

Common use cases

  • Inspect BSON payloads next to JSON when debugging MongoDB drivers or wire dumps.
  • Compare BSON size against MessagePack or CBOR for the same object.
  • Share Base64 BSON snippets in tickets without installing a local CLI.
  • Sanity-check a driver’s serialize path by round-tripping a small document before hitting a shared cluster.

Common mistakes to avoid

  • Encoding a bare JSON array

    BSON documents are objects; wrap arrays in a property (e.g. {"items": [...]}) before encoding.

  • Expecting exact ObjectId types in JSON

    After decode, ObjectId and other BSON types appear as JSON-friendly values—match your driver’s expectations.

  • Assuming Decimal128 and double are interchangeable

    Financial decimals and IEEE doubles behave differently. After BSON → JSON, confirm numeric types match how your app persists money or metrics.

FAQ

Is BSON encoding local?

Yes. Parsing and serialization run entirely in your browser.

Does this replace mongosh?

No—it is a quick binary round-trip helper. Use database tools for production queries.

Is BSON the same as Extended JSON?

Related but not identical—drivers often emit Extended JSON for debugging. Here you move between BSON bytes (Base64) and plain JSON for quick inspection, not every MongoDB shell dialect.

Common search terms

Phrases people search for that match this tool. See the full long-tail keyword index.

  • json to bson online
  • decode bson base64 mongodb

Related utilities you can open in another tab—mostly client-side.