XML to Base64 Converter

Encode an XML document to Base64, with an optional check that the tags balance before you send it.

XML
Base64
Runs locally in your browser

About the XML to Base64 Converter

XML carried inside another format needs armour. A SOAP envelope stored in a JSON attribute, a signed invoice in a database column, an RSS snapshot inside a message body: in each case the raw angle brackets and quotes would collide with the container. Base64 removes that risk by reducing the whole document to safe characters.

The optional well-formedness check parses the document before encoding and refuses to continue if a tag is unclosed or an ampersand is bare. Catching that before transmission is far cheaper than debugging a rejection from a partner system hours later. Leave the check off when you are deliberately encoding a fragment that has no single root element.

Output can be raw Base64 for an API field, or a data:application/xml URI for tooling that accepts one. The document is encoded from its UTF-8 bytes, so a Nordic client name or a Chinese product description is preserved exactly. The URL-safe alphabet and the two wrap widths cover tokens and MIME bodies.

Shrink the payload first with XML Minifier, since Base64 adds a third on top of whatever you feed it, and use Base64 to XML to read an encoded document.

How to use

  1. Paste your XML document into the left pane.
  2. Tick Check that the XML is well-formed to catch unclosed tags before encoding.
  3. Choose raw Base64 or a data URI, then copy the encoded output.

Common questions

Should I strip the XML declaration first?
No. It is part of the document and decoders expect it, so leave it in place.
Why does the check reject a valid looking fragment?
A fragment with two sibling elements has no single root, which is not well-formed XML. Wrap it in a root element or switch the check off.
Does encoding preserve my indentation?
Yes, byte for byte. Minify the document first if you want a shorter result.
Is a bare ampersand a problem?
With the check on, yes: it must be written as &. With the check off it is encoded as it stands and will fail at the far end.