Base64 Encoder / Decoder

UTF-8 aware both ways. Emoji and CJK survive the round trip, which is where most online converters break.

Output
—

Worked example

Base64 is not encryption and not compression. It inflates data by about 33% and anyone can reverse it. It exists so binary can travel through channels that only accept text.

Base64 maps every 3 bytes to 4 printable characters. That is the whole algorithm. Its purpose is transport: email bodies, JSON fields, data URIs, HTTP basic auth, and JWT segments all need binary to survive a text-only channel.

The UTF-8 trap

The browser btoa() function accepts only Latin-1. Pass it a string containing CJK or an emoji and it throws InvalidCharacterError. This page encodes to UTF-8 bytes first, so the output matches what other languages produce and decodes back to the original text. If a converter mangles accents or refuses emoji, that is the bug.

URL-safe variant

Standard base64 uses + and /, both of which have meaning inside a URL or a filename. The URL-safe alphabet substitutes - and _ and drops the padding. JWTs use it — a token with a + in it is a standard-alphabet token that will not survive a query string.

What it is not

Encoding something in base64 does not hide it; the first thing anyone does with an unknown blob is decode it. Do not use it to obscure passwords, API keys or personal data.