Codec lesson · Base64

Base64: package text in a portable alphabet

Base64 turns bytes into characters from a 64-symbol alphabet. It is convenient for transport, but it is immediately reversible and is not encryption.

Standard · RFC 4648 Round trip: Exact for canonical Base64 whose bytes are valid UTF-8 text.
Learning objective

Base64 turns bytes into characters from a 64-symbol alphabet. It is convenient for transport, but it is immediately reversible and is not encryption.

Encode Keyboard reads the UTF-8 bytes of your text and emits standard Base64 using A–Z, a–z, 0–9, + and /. An equals sign may pad the final four-character block.

01

How Encode Keyboard handles it

1

Start with UTF-8 bytes

Unicode text is encoded consistently before Base64 begins.

2

Re-group the bits

Groups of three bytes become four Base64 characters, with padding when needed.

3

Require canonical text

Decode ignores whitespace, then checks the standard alphabet, block length, padding, canonical re-encoding, and valid UTF-8 output.

02

Worked example

InputHello
OutputSGVsbG8=

The final = is padding; it is part of this canonical Base64 value.

03

Good uses

  • Understanding text-safe byte transport
  • Inspecting Base64 text from APIs and files
  • Creating reversible snippets for non-sensitive data
04

Validation and common errors

  • Output grows by roughly one third
  • Malformed padding or non-canonical forms are rejected
  • Encoded content remains readable to anyone
05

Practice in your browser

This uses the same documented rules as the app and runs only in this tab.

Base64This uses the same documented rules as the app and runs only in this tab.
Result

This uses the same documented rules as the app and runs only in this tab.

06

Knowledge check

What does the = at the end of some Base64 values do?