XML Input

Base64 Output

What Is XML to Base64?

Sometimes you need to embed an XML document inside a JSON field, a database column, or a network payload — but raw XML with angle brackets and quotes causes all kinds of escaping headaches. Base64 encoding converts XML into a safe ASCII string that travels anywhere without corruption. This tool does that in one step: paste your XML, get a Base64 string back. It also decodes in the other direction, which is handy when you receive a Base64 blob and need to inspect the XML inside. Check the MDN Base64 guide if you want to understand how the encoding works under the hood. Everything runs locally in your browser — nothing is sent to any server.

How to Use This Tool

1

Choose Mode

Select Encode to convert XML to a Base64 string, or Decode to go the other way.

2

Paste Input

Paste your XML (or Base64 string) into the left editor. Use Sample to load an example, or Upload to load from a file.

3

Copy or Download Result

The Base64 output can be used in APIs or stored safely. Need to escape XML instead? Try XML Escape. Want to convert XML to another format? Try XML to JSON.

Example

Encoding a simple XML document to Base64 — a common pattern when embedding XML in JSON or sending it over text-only channels:

Encoding XML to Base64

XML:

Encoded as Base64:

Base64:

Click the Sample button to load example XML and see the Base64 output instantly.

When does XML to Base64 help?

Useful when embedding XML in JSON payloads, storing XML in databases that don't support special characters, or transmitting XML over channels that expect plain ASCII text.

Frequently Asked Questions

Why would I encode XML to Base64?

Base64 turns XML into a plain ASCII string, which is safe to embed in JSON values, URL parameters, HTTP headers, or any system that chokes on raw angle brackets and quotes. It's a common pattern in SOAP APIs, config storage, and data serialization. See RFC 4648 for the full spec.

How do I decode a Base64 string back to XML?

Switch to Decode mode and paste the Base64 string. The tool decodes it using the browser's built-in atob() function. If the string starts with a Data URI prefix like data:application/xml;base64,, that prefix is stripped automatically.

Does this work with XML that contains UTF-8 characters?

Yes. The encoder uses btoa(unescape(encodeURIComponent(xml))) internally, which correctly handles multibyte UTF-8 characters like accented letters, Chinese, Arabic, and Cyrillic. Standard btoa() alone would fail on those — this tool handles it for you.

Can I encode large XML files?

You can paste or upload XML files of any size the browser can handle. Use the Upload button to load a file directly instead of pasting. Keep in mind that Base64 output is about 33% larger than the input.

Is my XML data private?

Absolutely. All encoding and decoding runs locally in your browser using JavaScript. No data is sent to any server. You can verify this yourself by checking your browser's Network tab while using the tool.

What is the difference between Base64 and Base64url?

Standard Base64 uses + and / characters, which need URL-encoding in query strings. Base64url replaces those with - and _. This tool produces standard Base64. If you need Base64url output, use our Base64 URL Encoder instead.

Related Tools

The Base64 encoding scheme is defined in RFC 4648. The XML specification lives at W3C XML. See also MDN: Base64.