Base64
Base64 is a binary-to-text encoding that represents arbitrary byte data using 64 printable ASCII characters, commonly used to safely embed binary data in text formats.
Updated: 2026-08-11
Lookup
Base64 | Definition |
|---|---|
Standard alphabet | A–Z, a–z, 0–9, +, / — 64 symbols, output padded with = to a multiple of 4 characters. |
Base64URL alphabet | Same as standard but + → -, / → _, so output is safe to use directly in URLs, filenames, and cookies. Padding is often omitted. See the Base64 vs Base64URL guide. |
Padding rule | 1 pad char if input length mod 3 == 2, 2 pad chars if mod 3 == 1, no padding if mod 3 == 0. |
Examples
Encoding "Man" (3 bytes, no padding needed)
text
"Man" (77, 97, 110) -> "TWFu"Encoding "Ma" (2 bytes, 1 pad char)
text
"Ma" (77, 97) -> "TWE="Common Mistakes
!
Assuming Base64 is encryption
Base64 provides no confidentiality — it's fully reversible without any key, by design.
!
Ignoring padding differences across libraries
Some encoders omit trailing = characters; a decoder that requires exact padding will reject otherwise-valid output.
!
Using standard Base64 directly in a URL
Standard Base64's + and / characters have special meaning in URLs and need percent-encoding — use Base64URL instead to avoid that entirely.
Related Concepts
Base64