Overview
Introduction
BSON bytes aren't human-readable on their own.
This tool decodes them and shows the equivalent XML.
What Is BSON to XML Converter?
A decoder that reads hex-encoded BSON bytes according to their element type codes and reconstructs a plain JS value.
It then converts that value into XML.
How BSON to XML Converter Works
The hex string is converted to raw bytes and read element by element: each element's one-byte type code determines how to read its value, a length-prefixed string, a 4 or 8-byte number, a nested document, and so on.
This rebuilds the original document as a plain object, which is then converted to XML.
When To Use BSON to XML Converter
Use it to inspect BSON data, from a MongoDB dump or wire capture, for instance, in a more familiar, readable format.
It's also useful for verifying an XML to BSON Converter round trip.
Often used alongside XML to BSON Converter, Bencode to XML Converter and BXML to XML Converter.
Features
Advantages
- Decodes the exact element-type subset the XML to BSON Converter and JSON to BSON Converter produce.
- Runs entirely client-side.
- Reports the specific unsupported type code when decoding fails, rather than a vague error.
Limitations
- Doesn't decode MongoDB-specific BSON types (ObjectId, Date, regex, binary data), only the practical subset listed in the FAQ.
- 64-bit integers are approximated using JS's double-precision numbers, matching the encoder's own approximation.
Examples
Best Practices & Notes
Best Practices
- Use hex generated by this site's own BSON encoders as a starting point if you're unsure what valid input looks like.
- Use XML to BSON Converter to produce hex from XML in the first place.
- Check the reported type code against the BSON spec if you hit an unsupported-type error.
Developer Notes
Decoding lives in `decode-bson.ts`, reading the exact element type codes `json-to-bson.ts`'s encoder writes, so the two stay in sync for round-tripping.
BSON to XML Converter Use Cases
- Inspecting BSON data from a MongoDB dump or wire capture in readable form
- Verifying an XML to BSON Converter round trip
- Debugging a BSON-producing pipeline by reading its output as XML
Common Mistakes
- Pasting hex containing MongoDB-specific types (ObjectId, Date), which this decoder doesn't support.
- Pasting hex from a different encoding (like BXML or Bencode), which uses an unrelated byte layout.
Tips
- Use XML to BSON Converter to produce hex from XML in the first place.
- Check the FAQ above if the output doesn't look like what you expected.