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.

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.

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.

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.

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.

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