Base64 Encode / Decode

Convert text to Base64 or decode Base64 back to text, with full support for Chinese and emoji

Base64, fully explained: encoding rules, padding, the 33% size penalty, and common myths

What Base64 actually does

Base64 remaps arbitrary binary data onto 64 printable characters: A-Z, a-z, 0-9, plus + and /. The mapping works in fixed chunks: every 3 bytes of input (24 bits) are split into 4 groups of 6 bits, and each group is looked up in the alphabet to produce one character. That is why the output length is always exactly 4/3 of the input length — there is no rounding, no per-character variation, just a fixed ratio.

The reason Base64 exists is not to hide data but to carry it through channels that only accept text. Email bodies over SMTP, HTTP headers, JSON string fields, XML text nodes, and URL query strings all choke or rewrite bytes that are not printable ASCII. Base64 turns any byte sequence into a character set those transports can hold without damage. Think of it as a courier that repackages a parcel so it fits through a narrow slot — the contents are unchanged, only the wrapping is different.

Where the = padding comes from

Input length is not always a multiple of 3, so the final block may be short. The encoder pads up to 4 characters using = to signal where the original data ended:

Input bytesOutput charsPaddingExample
14== two"a" becomes YQ==
24= one"ab" becomes YWI=
34none"abc" becomes YWJj

The padding carries no information — it only marks "the original data stopped here." Some systems strip it to save space, but once stripped the length is no longer divisible by 4, and the decoder must reconstruct the padding before it can parse. Base64 padding is optional on the wire, but the decoder's handling of it must be correct, or you get a corrupted final byte. If you have ever seen a Base64 string that decodes fine except for a garbage last character, a missing or miscounted = is the usual cause.

The size penalty: not "about the same," but a real 33%

The 4/3 ratio means a volume increase of roughly 33.3%. A 300 KB image encoded as Base64 becomes about 400 KB. Stack a couple of layers — Base64 inside JSON inside another Base64 — and the bloat compounds multiplicatively, not additively.

That overhead creates several concrete traps in everyday engineering:

URL-safe variants: why + and / get swapped

The standard Base64 alphabet contains + and /, both of which carry special meaning inside URLs (they stand in for spaces and path separators). Drop them straight into a URL and they get re-encoded or truncated. RFC 4648 section 5 defines the URL-safe variant:

VariantAlphabet differencePaddingTypical use
Standard Base64+ /keptemail attachments, data URIs
Base64url- _usually strippedJWTs, URLs, file names
MIME Base64standard alphabetkeptemail body, line-wrapped at 76 chars

The catch: Base64 and Base64url produce different output and cannot decode each other. Feed the - and _ of a JWT to a decoder that only knows the standard alphabet and you get garbage. This tool supports both flavors so you can round-trip either one correctly.

Base64 is not encryption, and not a hash

These three concepts get conflated constantly, yet they are completely different in nature:

ReversibleNeeds a keyPurpose
Base64 encodingyesnolet data cross text-only channels safely
Encryption (AES, etc.)yesyesconfidentiality
Hashing (SHA-256, etc.)nonointegrity verification

Anyone can decode Base64. Running a password, an API key, or a national ID number through Base64 before sending it is identical to sending it in plaintext. Open the browser console, type one line of atob(), and the original is back. If you truly need secrecy, transport it over TLS or use authenticated encryption such as AES-GCM.

A checklist of common mistakes

When to reach for it, and when not to

Use it to embed binary data into text protocols (JWTs, email, XML, JSON), inline small icons into CSS, log binary fragments safely, or build a Basic Auth header. Do not use it to transmit sensitive data (use TLS), store passwords (use bcrypt or argon2), move large files over HTTP (use multipart or raw binary to reclaim that 33% of bandwidth), or in any compression pipeline where you forgot to compress before encoding — reverse the order and the compression does nothing.

Everything here runs locally in your browser; nothing is sent anywhere. When processing a large file, open the Network panel in your dev tools to confirm there are no outbound requests.

FAQ

Why is the decoded output garbled?

The input may not be Base64, or it may encode binary data such as an image. This tool decodes as UTF-8 text, so binary content shows as garbage, which is expected.

Is my data uploaded to a server?

No. Encoding and decoding happen entirely in your browser, with no network requests.

Does it support Chinese and emoji?

Yes. The tool converts to UTF-8 bytes first, so Chinese characters and emoji round-trip correctly.