How it works
3 bytes → 4 lettersText is first turned into bytes (UTF-8: plain letters take one byte, “☕” takes three). Base64 then takes the bytes three at a time, 24 bits, and cuts them into four 6-bit pieces. Each piece is a number from 0 to 63, and that number picks a letter from the 64-character alphabet below. Here are your first bytes going through it:
-
Why it’s about a third bigger
every 3 bytes → 4 characters, so size × 4 ÷ 3 (rounded up to a multiple of 4) -
Padding
1 byte left over → 2 letters + “==”, 2 bytes left over → 3 letters + “=”
The Base64 alphabet
RFC 4648- 0A
- 1B
- 2C
- 3D
- 4E
- 5F
- 6G
- 7H
- 8I
- 9J
- 10K
- 11L
- 12M
- 13N
- 14O
- 15P
- 16Q
- 17R
- 18S
- 19T
- 20U
- 21V
- 22W
- 23X
- 24Y
- 25Z
- 26a
- 27b
- 28c
- 29d
- 30e
- 31f
- 32g
- 33h
- 34i
- 35j
- 36k
- 37l
- 38m
- 39n
- 40o
- 41p
- 42q
- 43r
- 44s
- 45t
- 46u
- 47v
- 48w
- 49x
- 50y
- 51z
- 520
- 531
- 542
- 553
- 564
- 575
- 586
- 597
- 608
- 619
- 62+
- 63/
Good to know
- Base64 is an encoding, not encryption: anyone can decode it. Don’t use it to hide passwords.
- You’ll see it in email attachments, data: URLs for images, and the middle part of login tokens (JWTs).