100% en el navegador y privado

Base64 Encoding Explained: Binary Data over Text Transports & RFC 4648

In modern computer networks, raw binary data (such as compiled executables, JPEG photographs, or encrypted cryptographic keys) must frequently traverse text-only transport channels—including MIME email protocols (SMTP), JSON API payloads, and HTML/CSS stylesheets. The Base64 encoding scheme (standardized in RFC 4648) solves this by translating arbitrary sequences of 8-bit bytes into an ASCII-safe alphabet that will never be corrupted by control character transformations or text encodings.

Encode & Decode Base64 in Your Browser

Use our client-side Base64 Converter to encode strings, inspect byte values, and decode Base64 data with zero latency.

Open Base64 Converter →

1. How Base64 Operates: The 6-Bit Translation Math

Standard computer data is stored in 8-bit bytes (values 0 to 255). Many byte values represent invisible control codes (like line breaks or NULL bytes) that break legacy mail servers. Base64 groups binary data into chunks of 6 bits (2&sup6; = 64 possibilities) and assigns each 6-bit index to a universally printable ASCII character:

3 Bytes (3 × 8 = 24 bits) ======> 4 Characters (4 × 6 = 24 bits)
► Step-by-Step Translation Example: The String «Man»
  1. ASCII Bytes: ‘M’ (77), ‘a’ (97), ‘n’ (110)
  2. Binary (8-bit): 01001101 01100001 01101110
  3. Regroup into 6-bit blocks: 010011 | 010110 | 000101 | 101110
  4. Decimal Values: 19, 22, 5, 46
  5. Lookup in Base64 Index: 19 → ‘T’, 22 → ‘W’, 5 → ‘F’, 46 → ‘u’
  6. Final Base64 Output: TWFu

2. The Base64 Character Index Table

The standard Base64 alphabet contains exactly 64 printable characters:

  • Indices 0 to 25: A-Z (Uppercase letters)
  • Indices 26 to 51: a-z (Lowercase letters)
  • Indices 52 to 61: 0-9 (Digits)
  • Index 62: + (Plus)
  • Index 63: / (Forward Slash)

3. The Role of the Padding Character (‘=’)

What happens if the input byte sequence is not a multiple of 3? Base64 handles partial blocks by adding zero-bits to the end and marking the missing bytes with the padding character =:

  • Input has 3 bytes: Produces 4 Base64 characters (no padding needed, e.g. TWFu).
  • Input has 2 bytes: 16 bits regroup into two 6-bit sextets plus 4 remaining bits. Outputs 3 characters plus one ‘=’ padding character (e.g. Ma → TWE=).
  • Input has 1 byte: 8 bits regroup into one 6-bit sextet plus 2 remaining bits. Outputs 2 characters plus two ‘==’ padding characters (e.g. M → TQ==).

4. The 33% Payload Expansion Overhead

Bandwidth Trade-Off: Because 3 raw bytes expand into 4 ASCII characters, Base64 encoding increases data size by approximately 33.3%. For example, a 3 MB image will expand to approximately 4 MB when Base64-encoded.

5. Data URIs in Web Development (Inlining Assets)

Web developers frequently inline small SVG icons or 1px placeholder images directly inside HTML or CSS to save HTTP requests using Data URIs:

data:[<mediatype>][;base64],<data>

While inlining saves a round-trip HTTP request, avoid inlining large assets because Data URIs cannot be independently cached by the browser’s HTTP cache.

6. Why Base64 is NOT Encryption (Security Alert)

Critical Security Misconception: Base64 is encoding, not encryption. Anyone can instantly decode Base64 back to original plaintext using standard command-line tools without any secret key. Never store passwords or sensitive API tokens in Base64 without true cryptographic encryption.

7. URL-Safe Base64 (RFC 4648 Section 5)

Standard Base64 contains + and /, which have special syntactic meanings in URL query parameters and filenames. URL-safe Base64 resolves this by substituting + with - (hyphen) and / with _ (underscore).

8. Frequently Asked Questions

Why does Base64 use ‘=’ instead of another character for padding?

The ‘=’ symbol is reserved specifically as a framing token in RFC 4648 because it does not exist in the 64-character payload alphabet. This allows parsers to immediately calculate exact byte alignment without parsing the full stream.