CalcPro

Base64 Encode / Decode

Encode text to Base64 or decode Base64 back to text.

How Base64 works

Base64 is a text-safe encoding system that converts any binary data into a string of 64 'safe' characters. It's not encryption—anyone can instantly decode it—but it's essential for transmitting data across systems that only reliably handle plain text (like email, JSON APIs, or HTML attributes).

The process works by grouping your input into chunks, converting each to a number, then mapping that number to one of 64 allowed characters (A–Z, a–z, 0–9, +, /). If the input length isn't a multiple of 3 bytes, padding characters (=) are added at the end.

The formula

Base64 = (input bytes) → (6-bit groups) → (lookup table) → (ASCII characters + padding)

Worked example

Encoding "Hello" to Base64:

  1. Convert each letter to its ASCII value:

    • H = 72, e = 101, l = 108, l = 108, o = 111
  2. Convert to binary (8 bits each):

    • 01001000 01100101 01101100 01101100 01101111
  3. Group into 6-bit chunks:

    • 010010 000110 010101 101100 011011 000110 1111 (last group has only 4 bits, pad with 00)
    • 010010 000110 010101 101100 011011 000110 111100
  4. Convert each 6-bit group to decimal:

    • 18, 6, 21, 44, 27, 6, 60
  5. Map to Base64 table:

    • 18=S, 6=G, 21=V, 44=s, 27=b, 6=G, 60=8
    • Result: SGVsbG8=

(The trailing = is padding because "Hello" is 5 bytes, not a multiple of 3.)

Decoding "SGVsbG8=" back to text:

  1. Remove padding (=) and convert each character back to 6-bit binary
  2. Regroup into 8-bit bytes
  3. Convert each byte to ASCII: 72, 101, 108, 108, 111
  4. Convert to characters: Hello

Common mistakes

  • Forgetting that Base64 is not encryption. If you encode a password as Base64 and share it, anyone can decode it. Always encrypt sensitive data first.
  • Assuming padding is optional. Padding (=) is required for valid Base64. Decoders expect it.
  • Mixing up encode and decode. If you paste Base64 into the Encode field, you'll get garbage. Use the correct action for your input type.
  • Losing special characters. When encoding, ensure your input is in UTF-8. Some legacy systems may not display emoji or accented text correctly after decoding if they don't support UTF-8.
  • Whitespace sensitivity. Newlines and spaces are encoded as data. If you copy Base64 from a formatted source, remove extra line breaks before decoding.

Frequently asked questions

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It uses 64 printable characters (A–Z, a–z, 0–9, +, /) to safely transmit or store data that might otherwise be corrupted by systems that only handle text.

Why would I need to encode text as Base64?

Common uses include embedding images in HTML/CSS, transmitting data over email or APIs, storing binary data in databases, and ensuring data integrity when moving files across systems with different character encodings.

Why is the encoded output longer than the original text?

Base64 uses 6 bits per character instead of 8, so it expands the output by roughly 33%. Every 3 bytes of input become 4 Base64 characters. Padding with '=' signs may be added at the end to complete groups of 4.

Can I decode any random Base64 string?

Only if it's valid Base64. The decoder will fail or produce gibberish if the input contains invalid characters or isn't properly padded. Valid Base64 uses only A–Z, a–z, 0–9, +, /, and = for padding.

Is Base64 encryption? Is it secure?

No. Base64 is encoding, not encryption. Anyone can decode it instantly. If you need to protect sensitive data, use encryption (like AES) *before* Base64 encoding.

Does this work with special characters and emojis?

Yes. The calculator handles UTF-8 encoded text, including accented letters, symbols, and emoji. They are first converted to UTF-8 bytes, then encoded to Base64.