Convert XML to Base64
Encode XML data as Base64 string. Paste XML, get Base64-encoded output instantly. 100% client-side.
Paste your XML, hit Encode, and grab a Base64 string you can safely drop into JSON fields, URL parameters, or config files — no angle brackets breaking things, no manual escaping. It handles UTF-8 content, SOAP envelopes, SVGs, and anything else wrapped in XML tags.
The output follows standard RFC 4648 Base64, with an optional line-wrap toggle at 76 characters for MIME compatibility. And everything runs in your browser. Nothing gets uploaded.
How It Works
The tool reads your XML as a UTF-8 string, then runs it through the browser's native btoa() function (with proper Unicode handling). Each byte gets mapped to a printable ASCII character from the Base64 alphabet — letters, numbers, plus, and slash. The result is a string that's safe for any text-based transport.
Examples
Simple Config File
Embedding a small app config inside a JSON API request body.
<config>
<timeout>30</timeout>
<retries>3</retries>
</config>
PGNvbmZpZz4KICA8dGltZW91dD4zMDwvdGltZW91dD4KICA8cmV0cmllcz4zPC9yZXRyaWVzPgo8L2NvbmZpZz4=
SOAP Envelope for API Testing
Storing a SOAP request template as a Base64 string in a test fixture, so angle brackets don't need escaping in the test runner.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetPrice>
<Item>Widget-A</Item>
</GetPrice>
</soap:Body>
</soap:Envelope>
PHNvYXA6RW52ZWxvcGUgeG1sbnM6c29hcD0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZlbG9wZS8iPgogIDxzb2FwOkJvZHk+CiAgICA8R2V0UHJpY2U+CiAgICAgIDxJdGVtPldpZGdldC1BPC9JdGVtPgogICAgPC9HZXRQcmljZT4KICA8L3NvYXA6Qm9keT4KPC9zb2FwOkVudmVsb3BlPg==
SVG Icon for Inline CSS
Converting an SVG to Base64 so it can be used as a CSS background-image without a separate HTTP request.
<svg viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10"/>
</svg>
PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiPgogIDxjaXJjbGUgY3g9IjEyIiBjeT0iMTIiIHI9IjEwIi8+Cjwvc3ZnPg==
Who Uses This
Embedding XML payloads inside JSON responses or storing SOAP templates in config files.
Encoding XML test fixtures so they survive copy-paste into test frameworks without escaping headaches.
Converting SVG icons to Base64 data URIs for inline CSS background images.
Passing XML configs through environment variables or CI/CD pipelines where special characters cause problems.
Common Mistakes
Double-encoding is the most common mistake. If your XML is already Base64, encoding it again creates a string that won't decode back to valid XML. Check whether your source data is raw XML or already encoded before pasting it in.
Some systems expect <?xml version="1.0"?> at the top. If you strip it before encoding, the decoded output later might get rejected by strict XML parsers. Include it unless you're certain the receiver doesn't need it.
Windows uses \r\n, Unix uses \n. The Base64 output will differ depending on which line endings your XML has. This matters when you're comparing encoded strings across platforms — normalize line endings first if consistency matters.
Technical Details
- Processing: 100% client-side — nothing uploaded
- Browser Support: Chrome, Firefox, Safari, Edge
- Encoding: Standard Base64 (RFC 4648)
- Character Set: UTF-8 input supported
- Output Size: ~33% larger than the raw XML input
Frequently Asked Questions
What is Base64 encoding used for with XML?
Base64 turns binary or structured text into plain ASCII characters. For XML specifically, it removes angle brackets and special characters that would break JSON fields, URL parameters, or email bodies. You get a single safe string you can drop anywhere text is expected.
Does Base64 encoding compress XML?
No, it actually makes it bigger. Base64 output is roughly 33% larger than the input. It is not a compression method — it's a way to represent data safely in text-only contexts. If you need smaller output, compress the XML with gzip first, then Base64-encode the compressed bytes.
Can I decode the Base64 back to XML?
Yes, Base64 is fully reversible. Run the encoded string through any Base64 decoder and you'll get your original XML back, byte for byte. Nothing is lost or changed during encoding.
Is my XML data safe when using this tool?
Completely. The encoding runs in your browser with JavaScript. Nothing gets sent to a server, stored in a database, or logged anywhere. Close the tab and it's gone.
Why does my Base64 output have an equals sign at the end?
That's padding. Base64 works in groups of 3 bytes. When your input length isn't divisible by 3, the encoder adds one or two = signs to fill out the last group. It's normal and expected — decoders know to ignore them.