Base64 Encoder & Decoder

Convert text to Base64 or decode Base64 back to readable text β€” with full Unicode support.

What Is Base64?

Base64 is an encoding scheme that converts binary data into a text representation using 64 printable ASCII characters β€” the uppercase and lowercase letters A–Z and a–z, the digits 0–9, and the symbols + and /. A padding character = is also used. The name "Base64" refers to the 64-character set used as the encoding alphabet.

The purpose of Base64 is to make arbitrary binary data safe for transport and storage in contexts that only handle text. Many protocols and systems were designed to handle only printable ASCII text β€” email (MIME), URLs, HTML attributes, JSON values, and XML all have this limitation. Base64 provides a reliable way to embed binary or unicode data in these contexts without corruption or misinterpretation.

How Base64 Encoding Works

Base64 encoding works by taking three bytes (24 bits) of input data at a time and splitting them into four 6-bit groups. Each 6-bit group is then mapped to one of the 64 characters in the Base64 alphabet (A=0, B=1, ... Z=25, a=26, ... z=51, 0=52, ... 9=61, +=62, /=63). If the input data is not divisible by 3, padding characters (=) are added to make the output length a multiple of 4.

This means Base64 increases the size of data by approximately 33% β€” three bytes of input become four characters of output. This overhead is the trade-off for ensuring the data can travel safely through text-only channels. For this reason, Base64 is used for transport and embedding, not for general-purpose compression or storage.

Common Uses of Base64

Email attachments: the MIME standard uses Base64 to encode binary email attachments (images, PDFs, executables) as text so they can be transmitted through email servers that only handle ASCII. Data URLs: images and other files can be embedded directly in HTML or CSS as Base64-encoded strings, eliminating the need for separate file requests β€” useful for small icons in email templates or offline applications. API authentication: HTTP Basic Authentication encodes credentials as Base64 in the Authorization header, though this is not encryption and should only be used over HTTPS. JWT tokens: JSON Web Tokens encode their header and payload sections using Base64Url, a URL-safe variant that replaces + with - and / with _ and omits padding. Cryptographic data: public and private keys, certificates, and signatures are commonly stored and transmitted in Base64-encoded PEM format.

Base64 vs Encryption

Base64 is not encryption. It is a reversible encoding β€” anyone can decode a Base64 string without any key or password. It provides no security or confidentiality whatsoever. The transformation is deterministic and public: the same input always produces the same output, and the output is trivially reversible. Never use Base64 to "hide" sensitive information β€” use proper encryption (AES, RSA, or similar) for that purpose. Base64 is solely about format compatibility, not security.

Frequently Asked Questions

Why does Base64 output end with = or ==?

The = characters are padding. Base64 works in groups of 3 input bytes producing 4 output characters. If the input length is not divisible by 3, the output is padded with one or two = characters to make it a multiple of 4. One = means one padding byte was added; == means two padding bytes were added. Some Base64 variants (like the one used in JWTs) omit padding.

What is the difference between Base64 and Base64Url?

Standard Base64 uses + and / as the 62nd and 63rd characters, which are special characters in URLs. Base64Url replaces + with - and / with _, making the encoded string safe to use in URLs and filenames without percent-encoding. Base64Url also typically omits the trailing = padding. JWT tokens use Base64Url encoding for this reason.

Does this tool support Unicode and emoji?

Yes. This tool encodes text to UTF-8 bytes before applying Base64, and decodes Base64 by converting the result from UTF-8 bytes back to text. This means it correctly handles all Unicode characters including accented letters (Γ©, Γ€, ΓΆ), non-Latin scripts (Arabic, Chinese, Cyrillic), and emoji (πŸ˜€, πŸŽ‰, βœ…). The standard JavaScript btoa/atob functions do not handle multi-byte characters β€” this tool uses TextEncoder and TextDecoder to handle UTF-8 correctly.

How do I decode a Base64-encoded image?

A Base64-encoded image embedded in HTML looks like this: <img src="data:image/png;base64,iVBORw0KGgo...">. To decode it, copy the Base64 string (everything after the comma), paste it in the Base64 field of this tool, and click Decode. The decoded result will be the raw binary data β€” note that it won't be human-readable since it's image data, not text. To view the image, the data URL format is needed.

Working With Base64 in Code

In JavaScript/Node.js: btoa(string) encodes to Base64 (ASCII only); atob(base64) decodes. For proper UTF-8 support: use TextEncoder to convert string to bytes, then process with Uint8Array. In Python: import base64; base64.b64encode(bytes_obj) and base64.b64decode(base64_string). In PHP: base64_encode(string) and base64_decode(string). In Java: java.util.Base64.getEncoder().encodeToString(bytes) and Base64.getDecoder().decode(string). In Bash/Linux: echo "text" | base64 to encode; echo "base64string" | base64 -d to decode.