BSON to XML Converter

Decodes hex-encoded BSON, doubles, strings, embedded documents, arrays, booleans, null, and integers, into a plain value, then converts that into XML, the reverse of Convert XML to BSON. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-23

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.

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

Decoding a small document

Input

2a 00 00 00 03 75 73 65 72 00 1f 00 00 00 02 6e 61 6d 65 00 04 00 00 00 41 64 61 00 02 61 67 65 00 03 00 00 00 33 36 00 00 00

Output

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <name>Ada</name>
    <age>36</age>
  </user>
</root>

The decoded document's fields become nested XML elements under a synthetic root.

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.

References

Frequently Asked Questions