All Tools
Categories
XML Tools 64 Email Marketing Tools 55 Import-Export Tools 50 JSON Tools 44 Number Tools 34 Text Tools 13 Shipping Freight Tools 5 Calculator 4
About Contact Privacy

JSON to BSON Converter

Convert a JSON document into binary BSON encoding directly in your browser. See a hex preview of the encoded bytes and download a .bson file compatible with MongoDB's binary JSON format. Free and private — nothing is uploaded.

JSON Input
BSON Hex Preview
Encoding runs entirely in your browser. Nothing is uploaded or stored.

About JSON to BSON Converter

JSON to BSON Converter encodes a JSON document into BSON — the compact binary format MongoDB uses internally to store and transmit documents. Paste in JSON and the tool builds a spec-compliant BSON byte stream, complete with the correct type tags, length prefixes, and little-endian number encoding, so you can see exactly how MongoDB would represent your document on disk.

The output is shown as a readable hex dump for inspection, and can be downloaded as a raw .bson file for use with tooling that expects MongoDB's native binary format.

Features

  • Spec-compliant encoding: Correct BSON type codes, length-prefixed strings, and little-endian integers and doubles.
  • Automatic type selection: Whole numbers in 32-bit range become BSON int32; everything else becomes a BSON double, matching standard JSON-to-BSON driver behavior.
  • Nested documents and arrays: Objects and arrays of any depth are encoded as embedded BSON documents.
  • Hex preview: Inspect the exact encoded bytes before downloading.
  • Download as .bson: Get a raw binary file ready for BSON-aware tooling.

How to Use

  1. Paste your JSON into the input box, or click "Load Sample" to see an example.
  2. Click Encode to BSON to generate the binary output.
  3. Review the hex preview and byte count.
  4. Download the .bson file for use with BSON-aware tools or MongoDB tooling.

Examples

Example 1: A simple document {"name":"Jane","age":30,"active":true} encodes to a compact BSON byte stream with a string element for name, an int32 element for age, and a boolean element for active, each preceded by its type byte and field name.

Example 2: A document with a nested address object and a tags array encodes each nested structure as its own embedded BSON document, exactly as MongoDB would store it internally.

Benefits

  • Understand MongoDB storage: See exactly how a document maps to BSON's binary representation.
  • Generate test fixtures: Produce real .bson byte streams for testing BSON-aware code.
  • No installation needed: No MongoDB driver or command-line tool required — everything runs in your browser.
  • 100% private: Nothing is uploaded — encoding runs locally in your browser.

Frequently Asked Questions

What is BSON?
BSON (Binary JSON) is a binary-encoded serialization format used internally by MongoDB to store documents. It represents the same kind of data as JSON — objects, arrays, strings, numbers, booleans, and null — but as compact binary bytes instead of human-readable text, with explicit type and length information built into the encoding.
Why would I convert JSON to BSON?
Developers convert JSON to BSON to inspect exactly how MongoDB will store a document, to generate test fixtures for database tooling, to learn the BSON binary format, or to produce a .bson file for use with tools that expect MongoDB's native encoding.
Does this tool produce real, spec-compliant BSON?
Yes. The encoder follows the official BSON specification for documents, strings, 32-bit integers, doubles, booleans, null, embedded documents, and arrays, matching the same byte output as MongoDB's official BSON driver for these standard JSON-compatible types.
How are JSON numbers encoded in BSON?
Whole numbers that fit within the 32-bit signed integer range (-2,147,483,648 to 2,147,483,647) are encoded as BSON int32. All other numbers, including decimals and very large integers, are encoded as BSON double (64-bit floating point), which matches how plain JavaScript numbers are handled by MongoDB's own JSON-to-BSON conversion.
What happens if my JSON top-level value is an array or a plain value instead of an object?
BSON documents are conceptually objects. If your top-level JSON is an array, it is encoded as a BSON array document. If it is a plain string, number, boolean, or null, it is automatically wrapped as {"value": ...} so it can still be encoded as a valid BSON document.
Are MongoDB-specific types like ObjectId or Date supported?
No. This tool works from standard JSON input, which has no native representation for MongoDB-specific BSON types such as ObjectId, Date, or Binary. Those types only exist once data is already inside MongoDB or expressed using a driver's specific object types, not in plain JSON.
Is my data uploaded anywhere?
No. Encoding happens entirely in your browser using JavaScript. Your JSON never leaves your device or gets sent to a server.