XML to BXML Converter

Encodes a parsed XML document as a compact binary tree (tags, attributes, text, comments, CDATA, and processing instructions each with a type byte and length-prefixed fields), shown as hex, a smaller and losslessly round-trippable alternative to text XML. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-23

Overview

Introduction

Text XML carries a lot of redundant syntax, repeated angle brackets, closing tags, quote characters.

This tool re-encodes the same document as a compact binary tree instead.

What Is XML to BXML Converter?

A binary encoder for this site's own BXML format: every node, element, text, comment, CDATA, processing instruction, gets a one-byte type tag.

Element nodes additionally store their tag name, self-closing flag, attributes, and children with explicit length prefixes.

How XML to BXML Converter Works

The XML is parsed into this category's standard node tree, then walked and serialized: each node writes a type byte followed by length-prefixed strings for its content, with elements additionally writing their attribute count/pairs and child count before recursing into children.

The resulting bytes are shown as hex.

When To Use XML to BXML Converter

Use it to explore binary tree encoding concepts.

It also works as a compact, losslessly round-trippable intermediate format within this tool suite.

Features

Advantages

  • Losslessly preserves the exact node tree, including comments, CDATA, and processing instructions, unlike the JSON-intermediate converters.
  • Runs entirely client-side.
  • Typically produces a more compact byte count than the equivalent text XML.

Limitations

  • Not an interoperable standard, other tools won't recognize this encoding; it only round-trips with this site's own BXML to XML Converter.
  • Output is shown as hex text for readability and copying, not raw binary bytes.

Examples

Encoding a small element

Input

<a/>

Output

00 01 01 00 01 61 01 00 00 00 00

A node count of 1, then the element's type byte, its tag name's length-prefixed bytes, a self-closing flag, and zero attributes/children.

Best Practices & Notes

Best Practices

  • Use this alongside BXML to XML Converter to see the format round-trip, rather than expecting other tools to read the hex output.
  • Keep the full hex string intact, including consistent spacing, when copying it elsewhere for decoding later.
  • Reach for XML to BSON or XML to Bencode Converter instead if you specifically need a real, external binary format.

Developer Notes

Encoding/decoding both live in `bxml-core.ts`; the format is a straightforward TLV (type-length-value) scheme over `XmlNode`, with `Uint16` length prefixes for strings, attribute counts, and child counts.

XML to BXML Converter Use Cases

  • Exploring how a binary tree encoding of XML might look
  • Producing a compact, losslessly round-trippable intermediate representation within this tool suite
  • Teaching or demonstrating TLV (type-length-value) binary encoding concepts using a familiar XML document

Common Mistakes

  • Expecting the hex output to be interoperable with any external "BXML" tool or library, none is standardized.
  • Editing the hex by hand, a single wrong byte anywhere shifts every length-prefixed field after it.

Tips

  • Use BXML to XML Converter to decode the hex back into readable XML.
  • Check the FAQ above if the output doesn't look like what you expected.

References

Frequently Asked Questions