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.

Developer Tools Converter Runs in your browser Free · no ads

Customize your widget

Theme
Auto follows the visitor's light/dark setting.
Style
Attribution on your page
Optional and entirely your choice. The exact line is shown in the code below; it links to the tool with rel="nofollow".
More options
Starting values
Leave blank to use the widget's defaults. Visitors can still change every value.

Live preview

Exactly what your visitors will see

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.

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

  1. 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)
  2. 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

Preview