Dev Converters
Encoding

Base64 Encoder / Decoder

Base64 encode or decode any text online. UTF-8 safe, handles emoji and multi-byte characters correctly. Runs entirely in the browser.

How it works

Base64 encoding turns arbitrary bytes into a subset of ASCII, which makes it safe to embed in email, URLs, JSON strings, and HTML data URIs. Every three bytes of input become four output characters drawn from a 64-character alphabet. Because the ratio is fixed, the encoded form is always about 33% larger than the original.

This tool handles UTF-8 properly. A common mistake is to call JavaScript's built-in `btoa` on a string containing emoji — it throws because `btoa` only accepts code points ≤ 0xFF. Here we first convert the string to UTF-8 bytes using `TextEncoder`, then encode those bytes. On decode, we do the reverse with `TextDecoder`.

Use cases include encoding credentials for HTTP Basic auth, embedding small images in CSS with data URIs, and stuffing binary payloads into JSON fields. Note that Base64 is not encryption — anyone can decode it trivially. If you need confidentiality, use a proper cipher like AES-GCM. If you need URL safety, use the base64url variant (`-` and `_` instead of `+` and `/`, no padding).

Frequently asked questions

Does this handle non-ASCII characters?
Yes. The encoder uses TextEncoder to convert to UTF-8 bytes first, so emoji and CJK characters round-trip correctly.
What variant of Base64 is used?
Standard RFC 4648 with + / = characters. For URL-safe encoding, swap + with - and / with _ and strip padding in a follow-up step.
Is there a size limit?
No hard limit — anything that fits in browser memory works. For multi-megabyte files consider a streaming approach instead of paste-in.

Related tools