Convert

Encode and decode base64

Both directions at once: what your text encodes to, and what it decodes to.

Base64 is not encryption. It is a way to carry bytes through something that only accepts text, and anyone can reverse it — which is why it must never stand in for a password or a secret.

The text is encoded as UTF-8 first, so accents, emoji and non-Latin scripts survive the round trip. An implementation that calls btoa on the raw string corrupts anything above U+00FF, which is a common bug in tools that only ever tested English.

Decoding accepts the URL-safe alphabet as well as the standard one and ignores whitespace, because base64 arrives wrapped at 76 characters in email more often than not. Bytes that are not valid UTF-8 are reported rather than turned into replacement characters, since that usually means a file or an image rather than text.

Questions

Is base64 secure?

No. It is reversible by anyone and must not be used to hide a password, a key or anything else secret.

Why is the output longer than the input?

Base64 uses four characters for every three bytes, so the encoded text is about a third longer. That is the cost of the format.

Can I decode an image?

The decoder returns text. An image’s bytes are not valid UTF-8, so it says so instead of printing replacement characters. A base64-to-file converter is a different tool.

Does the URL-safe alphabet work?

Yes. - and _ are accepted and treated as + and /.

More text and code