Back to tools

JSON to BSON

Serialize JSON to BSON. MongoDB's binary format. Get hex, base64, and byte count using the official bson library. Runs in your browser. No data sent.

0 chars
0 chars

How It Works

  1. 1

    Paste JSON

    Top-level document. Wrap arrays or scalars in an object first.

  2. 2

    Serialize to BSON

    We encode using the official `bson` library, in your browser.

  3. 3

    Read hex and base64

    Both representations plus the byte count are shown.

Use Cases

  • MongoDB payload sizing

    See exactly how many bytes a document will consume on disk.

  • Inspect typed values

    Round-trip Extended JSON to BSON to verify ObjectId and Date serialization.

  • Craft test payloads

    Generate raw BSON hex for low-level MongoDB driver tests.

  • Wire format debugging

    Decode network captures of MongoDB protocol traffic.

Frequently Asked Questions

BSON (Binary JSON) is the binary-encoded serialization format used by MongoDB. It extends JSON with typed values like ObjectId, Date, Decimal128, and binary data, and is more compact and faster to traverse than text JSON for storage and transport.
It takes a JSON document, serializes it to BSON using the official `bson` library, and shows you both the hex and base64 representations along with the total byte count. Useful for inspecting what MongoDB will actually store, or for crafting raw BSON test payloads.
Not yet in this tool — it currently goes one direction (JSON → BSON). If you have raw BSON bytes, decode them in Node with `BSON.deserialize(Buffer.from(hex, "hex"))` from the `bson` npm package, then `JSON.stringify` the result. We may add the reverse direction here if there is demand — let us know at support@bug0.com.
Yes. BSON requires a top-level document (object). Wrap arrays, numbers, or strings inside an object first.
All standard JSON types: string, number, boolean, null, array, object. For typed BSON values like ObjectId or Decimal128, use MongoDB's Extended JSON syntax (e.g. `{"$oid": "…"}`) in your input.
No. Serialization runs entirely in your browser using a JavaScript BSON library.
BSON adds type tags, key terminators, and length prefixes to every value. For small documents BSON is often larger than JSON; the savings show up at scale and during traversal.

Done generating test data? Now automate the tests.

Bug0's expert AI agents write end-to-end tests from plain English, auto-heal them when your UI changes, and run them on every deploy. A forward-deployed engineer verifies every result.

From $2,500/mo. Results in 7 days.

Go on vacation. Bug0 never sleeps. - Your AI QA engineer runs 24/7

Go on vacation.
Bug0 never sleeps.

Your AI QA engineer runs 24/7 — on every commit, every deploy, every schedule. Full coverage while you're off the grid.