XML to Base64 Encoder
Encode XML as Base64. Unicode-safe, with URL-safe output available.
Input
Output
Ready
Drop a file to load it
About this tool
Encode an XML document as Base64 — for embedding in a data URI, a JWT payload, or any transport that only guarantees ASCII.
When you would use it
- Embedding XML in a data URI
- Putting a payload in a header or environment variable
- Transporting data through an ASCII-only channel
Worked example
<?xml version="1.0" encoding="UTF-8"?>
<user id="4815">
<name>Ada Lovelace</name>
<active>true</active>
<score>91.5</score>
<roles>
<role>admin</role>
<role>editor</role>
</roles>
</user>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHVzZXIgaWQ9IjQ4MTUiPgogIDxuYW1lPkFkYSBMb3ZlbGFjZTwvbmFtZT4KICA8YWN0aXZlPnRydWU8L2FjdGl2ZT4KICA8c2NvcmU+OTEuNTwvc2NvcmU+CiAgPHJvbGVzPgogICAgPHJvbGU+YWRtaW48L3JvbGU+CiAgICA8cm9sZT5lZGl0b3I8L3JvbGU+CiAgPC9yb2xlcz4KPC91c2VyPg==
Things worth knowing
- Encoding goes through UTF-8 bytes, so non-Latin text and emoji are handled correctly — unlike
btoa, which throws on them. - A URL-safe mode swaps
+and/for-and_and drops padding, for use in URLs and filenames. - Base64 is an encoding, not encryption. Anyone can decode it.
Questions
Frequently asked
Why not just use btoa()?
btoa only handles Latin-1 and throws on any character above U+00FF, which includes most non-English text and every emoji. This encoder converts to UTF-8 bytes first, so it works on any input.Is Base64 secure?
No. It is an encoding, trivially reversible by anyone. Never use it to protect secrets.
Is my data uploaded anywhere?
No. Every tool on JSONWorks runs entirely in your browser using JavaScript. Your input is never sent to a server, never logged and never stored. The simplest proof is to disconnect from the internet — the tools keep working. The site does load Google Fonts and a Google Analytics page-view tag, so you will see those two requests in your network tab, but neither receives anything you type or paste.
Related