Base64 Encode / Decode

Convert text to Base64 and back, including UTF-8 and URL-safe variants.

Direction
0 characters
Encoding options

What Base64 is for

Base64 turns arbitrary bytes into text made up of only 64 printable ASCII characters (A–Z, a–z, 0–9, "+", "/"), plus "=" for padding. That makes it safe to embed binary data — or text using characters some systems can't handle — inside formats that only guarantee plain ASCII will survive: email (MIME attachments), URLs, JSON strings, and configuration files. The trade-off is size: Base64 output is roughly a third larger than the original data.

It is not encryption. Encoding and decoding require no secret, so Base64 should never be used as a way to hide sensitive data — only to safely transport it through systems that would otherwise mangle raw bytes.

Example

Encoding Hello, world! produces:

SGVsbG8sIHdvcmxkIQ==

Where you'll run into Base64

Doing it in code

JavaScript

const encoded = btoa(unescape(encodeURIComponent(text))); // legacy pattern
const decoded = decodeURIComponent(escape(atob(encoded)));
// or, more directly, on modern engines:
const encoded2 = Buffer.from(text, "utf8").toString("base64"); // Node.js

Python

import base64
encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")
decoded = base64.b64decode(encoded).decode("utf-8")

Base64 Encode / Decode FAQ

Is Base64 encryption?

No. Base64 is a reversible encoding, not a cipher — anyone can decode it back to the original text with no key or password. It exists to safely represent binary or Unicode data using only the 64 characters that are guaranteed safe in contexts like email headers, URLs, and older text-only systems.

What is “URL-safe” Base64?

Standard Base64 uses "+" and "/", both of which have special meaning inside a URL. The URL-safe variant replaces them with "-" and "_" so the encoded text can be used directly in a URL path or query string without extra escaping.

Why does decoding sometimes fail?

Base64 text must be made up only of A–Z, a–z, 0–9, "+", "/" (or "-", "_" for the URL-safe variant) and optional "=" padding. If you paste text that includes line breaks from an email client, or the string was truncated, decoding will report exactly what looks wrong.

Does this handle emoji and non-English text?

Yes — text is encoded as UTF-8 bytes before Base64, so accented letters, CJK text and emoji all round-trip correctly.