DevBox Fast developer utilities, no signup

Base64 Encode/Decode

Type or paste text, then encode or decode. Unicode and emoji work correctly — nothing you enter leaves your browser.

Unicode-correct Base64, not just ASCII

Base64 encodes bytes, not characters, so the first step for text is turning your string into bytes — and that's exactly where naive implementations break. This tool converts your text into its correct UTF-8 byte sequence with TextEncoder first, then Base64-encodes those bytes, and reverses that with TextDecoder on the way back:

function toBase64(str) {
  return btoa(String.fromCharCode(...new TextEncoder().encode(str)));
}
function fromBase64(b64) {
  return new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0)));
}

The common shortcut, plain btoa(text), assumes one byte per character (Latin-1) and breaks the moment you type an accented letter, a Greek character, or an emoji — this tool doesn't have that problem, because it never hands raw characters to btoa in the first place.

Worked example

Encoding café 😀 (an accent and an emoji together) produces exactly:

Y2Fmw6kg8J+YgA==

Decoding that string returns café 😀 exactly — every character intact. Feed the same input through plain btoa() directly and it throws an error, because 😀 falls outside Latin-1.

Frequently asked questions

What is Base64 actually for?

Base64 turns arbitrary bytes into a string built only from letters, digits, +, /, and = — an alphabet that's safe to put anywhere plain text is expected. That matters because plenty of formats can't carry raw binary cleanly: email attachments (MIME encodes them as Base64), data URIs (embedding a small image directly in CSS or HTML as data:image/png;base64,...), and JSON or XML fields that need to carry binary-ish content without breaking the surrounding syntax.

Why do emoji and accented letters break some Base64 tools?

JavaScript's plain btoa() assumes every character fits in one byte (0–255) and corrupts or throws on anything outside that range — so é, an emoji, or Greek letters come out wrong. This tool encodes with TextEncoder first, which turns your string into its correct UTF-8 byte sequence, and Base64-encodes those bytes instead of the raw characters; TextDecoder reverses it on the way back. That's why café, emoji, and non-Latin scripts round-trip correctly here, unlike a naive btoa(text).

Is Base64 encryption or a security measure?

No — this matters. Base64 is an encoding, not a cipher: it has no key and no secret, and anyone can decode it instantly with any online tool or one line of code. If you see credentials or tokens 'protected' by Base64, they are not protected at all — treat it purely as a text-safety format, never as a way to hide or secure information.

Can I encode files with this tool?

Not currently — this works on text you type or paste, not file uploads. Encoding a file's raw bytes to Base64 (the way browsers do internally for data URIs) is a related but different job that this tool doesn't perform.