b2KIT

BSON Viewer & Converter

Inspect BSON (Binary JSON) documents and convert between BSON and JSON formats.

Tested tool guide Tested browser tools Checked August 16, 2026

What BSON Viewer & Converter does and how it behaves

BSON records values as typed binary elements rather than JSON text. This viewer decodes a BSON document into a readable field structure and converts between BSON and JSON representations, making type and nesting differences visible. It is useful when valid BSON cannot be inspected as ordinary text. The common surprise is that plain JSON cannot faithfully represent every BSON value: ObjectId, binary data, dates, Decimal128 values, and separate integer widths may require a type-preserving representation to survive a round trip.

How the result is produced

1

Reading BSON structure

A BSON document begins with its total byte length and then stores a sequence of typed elements terminated by a zero byte. Each element carries a type code, a null-terminated field name, and type-specific bytes. The viewer interprets that structure to separate fields, nested documents, arrays, strings, numbers, binary values, and other BSON types.

2

Converting JSON values

During JSON-to-BSON conversion, object members become BSON elements, nested objects become embedded documents, and arrays become BSON arrays. The reverse direction must express BSON values as JSON text. Values without native JSON counterparts need a type-preserving JSON convention; otherwise ObjectId, binary data, dates, Decimal128 values, and distinct integer widths can lose type information.

Good uses

  • Decode a BSON payload captured during debugging and inspect its fields without manually reading binary type codes and lengths.
  • Convert a small JSON fixture into BSON before testing software that expects a BSON document.
  • Compare decoded BSON with expected JSON when diagnosing changed numeric types, nested values, or binary fields.

Limits and checks

  • JSON number syntax does not distinguish BSON int32, int64, double, and Decimal128 values, so a conversion may not preserve the original numeric type.
  • A truncated document, incorrect declared length, missing terminator, or malformed type payload is not valid BSON and should not be treated as a partial result.
  • Readable JSON can be a representation of BSON rather than an exact ordinary-JSON equivalent, especially for ObjectId, dates, regular expressions, and binary subtypes.

Common questions

Is BSON compressed JSON?

No. BSON is a typed binary serialization format, not a compression format for JSON text. It stores information such as element type codes, document lengths, and field names. BSON may be faster for software to traverse in some contexts, but it is not guaranteed to occupy fewer bytes than an equivalent JSON document.

Will BSON to JSON to BSON reproduce identical bytes?

Not necessarily. Byte-for-byte reproduction requires the JSON representation to retain every BSON type, value, field order, and binary subtype. Plain JSON cannot express several of those distinctions. Two BSON documents can also describe similar visible data while using different numeric types or other encodings, so compare types as well as displayed values.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools