Convert JSON to BSON
Convert JSON data to BSON (Binary JSON) format. View BSON hex encoding and byte representation of JSON objects for MongoDB and other BSON-based databases.
Online JSON to BSON Converter
This free online JSON to BSON converter transforms your JSON data into BSON (Binary JSON) byte representation directly in your browser. BSON is the binary encoding format used by MongoDB and other document databases to store JSON-like documents in a compact, machine-readable binary format. This tool lets you preview the BSON encoding of your JSON objects in multiple formats including hex, decimal, binary, and Base64.
What is BSON?
BSON (Binary JSON) is a binary serialization format designed by MongoDB for storing documents and making remote procedure calls. It extends JSON with additional data types not supported in JSON, such as Date, ObjectId, BinData, Decimal128, and 32/64-bit integers. BSON is optimized for fast traversal and efficient encoding over the wire.
BSON vs JSON
- Binary format: BSON is stored as binary bytes, while JSON is plain text. BSON is faster to parse in database contexts.
- Additional types: BSON supports dates, binary data, regular expressions, and ObjectIds which JSON cannot natively represent.
- Size: BSON can be larger or smaller than JSON depending on the data, because it encodes type information and lengths inline.
- MongoDB native: MongoDB uses BSON as its primary storage and wire format for all document operations.
Frequently Asked Questions
Can I convert arrays or primitive values to BSON?
BSON encoding requires a JSON object (key-value document) as input. Arrays and primitive values (strings, numbers) cannot be serialized directly to BSON in the standard MongoDB driver format. Wrap your data in an object if needed.
What output formats are available?
The tool supports hexadecimal (space-separated and compact), decimal byte values, 8-bit binary representation, and Base64 encoding of the BSON bytes.
Is the output a real downloadable BSON file?
The tool converts JSON to BSON bytes and shows the human-readable representation. The download is the text representation of those bytes, not the raw binary BSON file. To use BSON in MongoDB, you would typically use the MongoDB driver directly in your application code.
Related tools
Your recent visits