What Is Base64 Encoding and How Does It Work?
Published 2026-08-20
4 min read
By CoShareX
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is widely used to transfer binary files (like images) over media that are designed to handle text.
How the Base64 Algorithm Works
Base64 encoding works by dividing every 3 bytes (24 bits) of binary data input into 4 groups of 6 bits each:
- Take 3 bytes (e.g.
ABC-> ASCII01000001 01000010 01000011). - Split into 4 groups of 6 bits:
010000(16)010100(20)001001(9)000011(3)
- Map each index to the standard Base64 character alphabet:
A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63).
- Index 16 maps to
Q - Index 20 maps to
U - Index 9 maps to
J - Index 3 maps to
D
- Result for
ABCisQUJD.
Featured Tool
Base64 Encoder / Decoder
Encode plain text to Base64 format or decode Base64 back to plain text.
Padding with =
If the input length is not a multiple of 3, Base64 adds zero bits to complete the last 6-bit group and appends one or two = padding characters to the end of the encoded string, indicating skipped bytes.