Loading JSON to BSON Converter...
Please wait a moment

How to Convert JSON to BSON - Step by Step Guide

Step 1

Input Your JSON Data

Let's convert your JSON to BSON format! Whether you're preparing data for MongoDB imports, working with MongoDB drivers, or optimizing storage, you have several convenient options:

•
Paste directly: Copy your JSON data from applications, APIs, or database exports
•
Upload a file: Click "Upload" to select a .json or .txt file from your computer
•
Try the sample: Click "Sample" to load example JSON and see the BSON conversion

Example: JSON Input

Here's a typical JSON structure ready for BSON conversion:

{
  "customerId": "CUST-12345",
  "phoneNumber": "+1555-1234567",
  "planType": "Unlimited 5G",
  "dataUsageGB": 45,
  "isActive": true
}
Step 2

Choose Output Format

Select how you want your BSON binary data to be encoded for display and transfer:

•
Base64 encoding: More compact format, ideal for APIs and web transmission
•
Hex encoding: Easier to debug byte-by-byte, useful for development
•
Arrays: keep a JSON array in one document, or write one document per item - the layout MongoDB's mongorestore reads

Example: BSON Output (Base64)

The same JSON, now encoded as BSON in Base64 format:

VgAAAAJjdXN0b21lcklkAA0AAABDVVNULTEyMzQ1AAJwaG9uZU51bWJlcgAPAAAAKzE1NTUtMTIzNDU2NwACcGxhblR5cGUADgAAAFVubGltaXRlZCA1RwAQZGF0YVVzYWdlR0IALQAAAAhpc0FjdGl2ZQABAAA=
Step 3

Export Your BSON Data

Get your encoded BSON ready for MongoDB! Multiple export options make integration seamless:

•
Copy to clipboard: One-click copying for quick pasting into MongoDB Compass or application code
•
Download as .bson: Save binary file for direct use with mongorestore and MongoDB imports
•
Ready for MongoDB: Optimized binary format with proper type information for efficient database operations

Frequently Asked Questions

How do I convert JSON to BSON for MongoDB?

Simply paste your JSON data into the converter, choose your preferred output format (Base64 or Hex), and the tool automatically encodes it to BSON. The converter handles all MongoDB-specific data types including ObjectId, Date, and Binary.

What's the difference between Base64 and Hex output?

Both represent the same BSON binary data as text. Base64 is more compact and commonly used for APIs and web transmission. Hex is easier to debug byte-by-byte and useful for development and troubleshooting.

How do I import the BSON into MongoDB?

If your JSON is an array, set Arrays to "One document per array item" first, then download the .bson file and point mongorestore at it, for example mongorestore --db shop --collection orders converted.bson. Each array item becomes one document in the collection. You can also copy the Base64 or Hex text and decode it with the BSON library of your MongoDB driver.

Does the converter support MongoDB-specific types?

Yes, through Extended JSON, the format mongoexport writes. A value such as {"$oid": "…"}, {"$date": "2024-01-15T09:30:00Z"}, {"$numberLong": "…"}, {"$numberDecimal": "…"}, {"$binary": …} or {"$timestamp": …} becomes the real BSON type. Plain JSON numbers are typed by size: whole numbers that fit in 32 bits become int32, larger ones an exact int64, and anything past 64 bits Decimal128, so long IDs keep every digit. Numbers with a decimal point or an exponent become doubles. Untick "Read Extended JSON" if you want those $ objects stored as ordinary fields.

Can I convert large JSON files to BSON?

Yes, up to BSON's own limit: one BSON document can be at most 16 MB, and MongoDB won't store anything bigger. For a large array, choose "One document per array item" so every item gets its own 16 MB allowance. Uploads are capped at 10 MB, and the conversion runs in your browser, so the data never leaves your machine.

Is this JSON to BSON converter free?

Yes, completely free with unlimited conversions. No registration required, and you can convert as much JSON to BSON as needed. All processing happens locally in your browser for security and privacy.