The Mathematics of Base64: Why It Increases Data Size by Exactly 33%
An in-depth mechanical explanation of 6-bit grouping, binary-to-ASCII translation, and padding bytes.
The Binary Constraint of Legacy Protocols
Early internet communication protocols (such as SMTP for email) were designed to transmit 7-bit ASCII characters. Sending raw 8-bit binary data (like images or compiled binaries) often caused characters to be stripped or corrupted.
Converting 8-bit Bytes to 6-bit Indices
Base64 takes three 8-bit bytes (24 bits in total) and partitions them into four 6-bit chunks (also 24 bits). Each 6-bit chunk has 2^6 = 64 possible combinations, matching the 64 characters of the Base64 alphabet: A-Z, a-z, 0-9, +, and /.
Original: [ 8 bits ] [ 8 bits ] [ 8 bits ] = 24 bits
Base64: [ 6 bits ] [ 6 bits ] [ 6 bits ] [ 6 bits ] = 24 bits
Ratio: 4 / 3 = 1.333... (exactly a 33.3% size expansion)Handling Padding Characters (=)
When input length is not divisible by 3, one or two '=' padding characters are appended so the total encoded length remains a multiple of 4.
Related Developer Tools
Put this theory into practice using our free companion tools: