Loading BSON Fixer...

How to Fix BSON Extended JSON Errors - Step by Step Guide

Step 1

Paste Your Broken BSON Extended JSON

Got broken BSON Extended JSON from your MongoDB exports? Let's fix it! After fixing, use our BSON validator, BSON to JSON converter, or BSON formatter. Paste your problematic BSON data:

Paste broken BSON: Copy error-prone Extended JSON from MongoDB Compass, mongodump exports, or application logs

Fix common errors: Automatically repairs broken $oid, $date, $numberLong wrappers, missing commas, and malformed documents

Try sample BSON: Click "Sample" to load broken BSON and see the tool in action

Note: For very large BSON documents, the server may not be able to handle the processing. Please use smaller document chunks for best results.

Example: Common BSON Extended JSON Errors

Here are typical BSON Extended JSON errors from MongoDB exports:

{
  "_id": { "$oid": "507f1f77bcf86cd79943901" },
  "name": "John Doe"
  "balance": { "$numberDecimal" "1250.75" },
  "created": { "$date": "2024-01-15T10:30:00Z },
  "status": active
}
Step 2

Review Detected BSON Errors

The tool scans your BSON Extended JSON and identifies all type wrapper and syntax errors:

Type validation: Checks $oid, $date, $numberLong, $binary, $regex, and other BSON type wrappers

Structural checks: Validates document nesting, array formatting, and key-value pairs

ObjectId validation: Ensures $oid values are valid 24-character hexadecimal strings

Most Common BSON Extended JSON Errors and How to Fix Them

1. Invalid ObjectId Length

MongoDB ObjectIds must be exactly 24 hexadecimal characters.

❌ Wrong:

{"$oid": "507f1f77bcf86cd79943901"}

✅ Correct:

{"$oid": "507f1f77bcf86cd799439011"}
2. Missing Colon in Type Wrapper

BSON type wrappers require proper JSON key-value syntax.

❌ Wrong:

{"$numberDecimal" "1250.75"}

✅ Correct:

{"$numberDecimal": "1250.75"}
3. Unclosed Date String

ISO date strings in $date must have matching quotes.

❌ Wrong:

{"$date": "2024-01-15T10:30:00Z}

✅ Correct:

{"$date": "2024-01-15T10:30:00Z"}
4. Unquoted String Values

All string values in BSON Extended JSON must be double-quoted.

❌ Wrong:

"status": active

✅ Correct:

"status": "active"
Step 3

Apply Fixes and Get Valid BSON Output

The BSON fixer automatically corrects all detected errors and produces clean, valid Extended JSON:

Auto-fix: Automatically correct type wrappers, missing commas, unquoted values, and structural issues

Validation: Confirm your BSON Extended JSON is valid and ready for MongoDB imports

Best Practices for Working with BSON Extended JSON

Use Extended JSON v2 (Canonical):

Prefer Extended JSON v2 canonical mode for data interchange, as it preserves all BSON type information unambiguously.

Validate ObjectIds Before Insertion:

Always ensure $oid values are exactly 24 hex characters before importing into MongoDB drivers.

Use mongoimport/mongoexport Correctly:

When using mongoimport, specify --jsonArray for arrays and ensure proper Extended JSON formatting.

Use ISO 8601 for Dates:

Always use ISO 8601 format strings in $date wrappers for cross-platform compatibility and clarity.

Frequently Asked Questions About BSON Fixer

What is BSON Extended JSON and how does it differ from standard JSON?

BSON (Binary JSON) is MongoDB's binary data format. Extended JSON is its human-readable text representation that preserves BSON-specific types like ObjectId, Date, Decimal128, and Binary using special wrapper objects like {"$oid": "..."}.

How do I fix broken BSON Extended JSON from MongoDB exports?

Paste your broken BSON Extended JSON into the editor above and click "Fix BSON!!". The tool automatically detects and repairs common errors like invalid ObjectIds, malformed type wrappers, missing commas, unclosed strings, and structural issues.

Can the BSON fixer handle documents exported from MongoDB Compass or mongodump?

Yes! The fixer handles BSON Extended JSON from any MongoDB tool including MongoDB Compass, mongoexport, mongodump output, and application-generated Extended JSON.

What BSON type wrapper errors can this repair tool fix automatically?

The fixer repairs broken $oid, $date, $numberLong, $numberDecimal, $numberInt, $binary, $regex, and $timestamp wrappers. It also fixes missing commas, unquoted keys and values, trailing commas, and malformed nested documents.

Is the BSON fixer free and does it support large MongoDB documents?

Yes, completely free with no registration required. The tool works best with small to medium BSON documents. For very large exports with many documents, consider breaking them into smaller chunks for optimal processing.

Can I convert fixed BSON to regular JSON or validate it?

Absolutely! After fixing your BSON, use our BSON to JSON converter, BSON validator, or BSON formatter to work with your data further.