Base64 Encoder / Decoder Widget
Embed a Base64 encoder and decoder that handles any language and emoji correctly. Readers can switch to the URL-safe alphabet used in JWTs and data URLs, and binary data is flagged instead of shown as garbage.
Live preview
Exactly what your visitors will seeUnder the widget on your page: Powered by A2Z Tools
Embed code
<iframe src="https://a2z.tools/embed/w/base64-encoder" title="Base64 Encoder / Decoder by A2Z Tools" width="100%" height="520" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>
A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.
<div data-a2z-widget="base64-encoder" data-height="520"></div> <script async src="https://a2z.tools/embed.js"></script>
Adds a small script (what it does) that sizes the widget to fit its content, loads it lazily and keeps it isolated from your page's CSS.
Works with
How it works
Base64 encodes bytes, not characters, so the widget first turns the text into UTF-8 bytes. The browser's plain btoa() function throws on anything outside Latin-1 ("Grüße ✓" fails), which is a common source of broken examples; this widget does not have that problem. Decoding strips whitespace, accepts both the standard and URL-safe alphabets with or without padding, validates length and padding, and then checks that the bytes are valid UTF-8. If they are not - an image or a zip file, for example - it says so and shows the first bytes in hex.
Method
- Alphabet: RFC 4648 section 4 (A-Z a-z 0-9 + /, padding =)
- URL-safe: RFC 4648 section 5 (- and _ instead of + and /, padding omitted)
- Text is encoded as UTF-8 before Base64; decoding requires valid UTF-8 to show text
- Output length = 4 x ceil(bytes / 3) characters with padding
Limitations
- Text only: it does not accept a file upload or produce a downloadable binary; decoded images or archives are shown as a hex preview.
- Decoded bytes that are valid UTF-8 are shown as text; bytes in Latin-1, Windows-1252 or UTF-16 are reported as binary rather than converted.
- MIME-style line wrapping at 76 characters is accepted on decode but never added on encode.
Where publishers use it
- HTTP Basic authentication and email (MIME) explainers
- Tutorials on data URLs and embedding small assets in CSS or HTML
- JWT and OAuth guides where readers need URL-safe Base64
- Debugging pages for webhooks or message queues that carry Base64 payloads
Questions
Is Base64 encryption?
No. It is an encoding that anyone can reverse. Never use it to hide passwords or secrets.
What is URL-safe Base64?
A variant from RFC 4648 that replaces + and / with - and _ and usually drops the = padding, so the result can sit in a URL or a JWT without escaping.
Why does decoding say the result is not text?
The Base64 contains binary data such as an image, not UTF-8 text. The widget shows the first bytes in hex instead of garbled characters.
Why does the output get longer?
Every 3 bytes become 4 characters, so Base64 is about 33% larger than the input.
Sources
- RFC 4648: The Base16, Base32, and Base64 Data Encodings - IETF . Section 4 alphabet, section 5 URL-safe alphabet, section 10 test vectors (checked in the tests)
- RFC 3629: UTF-8, a transformation format of ISO 10646 - IETF . Text-to-byte encoding and the validity check on decode
Cite or recommend this tool
If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.
A2Z Tools Base64 Encoder / Decoder https://a2z.tools/base64-encoder
<a href="https://a2z.tools/base64-encoder">A2Z Tools Base64 Encoder / Decoder</a>
[A2Z Tools Base64 Encoder / Decoder](https://a2z.tools/base64-encoder)
Base64 Encoder / Decoder by A2Z Tools - https://a2z.tools/base64-encoder
Related widgets
-
Percent-encode or decode text and URLs, and find the exact position of a malformed escape.
-
Read a JSON Web Token's header and claims, with exp, nbf and iat shown as dates.
-
MD5, SHA-1, SHA-256, SHA-384 and SHA-512 of any text, in hex or Base64.
-
Pretty-print, minify or validate JSON, with the line and column of the first syntax error.
-
Convert a JSON array of objects to CSV and CSV back to JSON, with RFC 4180 quoting.
-
Generate 1 to 100 random v4 or time-ordered v7 UUIDs in several formats.