Base64 Size & Bandwidth Overhead Calculator
Computes the encoded size of data in Base64 and the overhead it adds. Padded Base64 turns every 3 bytes into 4 characters, so n bytes encode to 4 × ⌈n ÷ 3⌉ bytes, or ⌈4n ÷ 3⌉ as unpadded base64url. MIME adds a CRLF after every 76-character line, PEM a line feed every 64 characters plus BEGIN and END lines, and a data URI its prefix. Extra bytes times monthly requests give the added transfer.
Enter the size of the data, pick how it will be encoded and how often it is sent, and the calculator returns the encoded size in bytes, the overhead in bytes and percent, the number of lines, and the extra transfer a month. A table compares every encoding for the same input. With the defaults, 100 KB of data becomes 133,336 bytes of padded Base64, 33.34% larger, and sending it a million times a month moves an extra 33.336 GB.
How Base64 turns 3 bytes into 4 characters
RFC 4648 defines Base64 with a 65-character subset of US-ASCII. The encoder takes the input 24 bits at a time, three 8-bit bytes, and splits each group into four 6-bit values, each of which picks one of 64 letters, digits and symbols. Each character is one ASCII byte, so every 3 bytes in become 4 bytes out. When the data runs out mid-group, the encoder adds zero bits to finish the last character and fills the group with the 65th character, "=": a final single byte becomes two characters and "==", and a final two bytes become three characters and "=".
padded = 4 × ⌈n ÷ 3⌉
The base64url alphabet in section 5 of the RFC swaps "+" and "/" for "-" and "_", which are safe in URLs and filenames. RFC 4648 says implementations must pad unless the referring specification says otherwise, and that padding can be skipped when the data length is known implicitly. JSON Web Signatures, RFC 7515, define base64url with every trailing "=" removed and no line breaks, so only the characters that carry bits are left:
unpadded = ⌈4n ÷ 3⌉
Line breaks, armor and prefixes
The 4:3 ratio is the floor. Most places that carry Base64 add something around it, and the calculator counts each addition in bytes.
MIME email, defined in RFC 2045, requires the encoded stream to be written in lines of no more than 76 characters. RFC 2045 separates those lines with a CRLF, two bytes, and RFC 2046 attaches the CRLF after a body part's last line to the multipart boundary that follows. The calculator counts a CRLF after every line, the last included, because on the wire that pair is present either way:
MIME = padded + 2 × ⌈padded ÷ 76⌉
PEM files follow RFC 7468, which requires each Base64 line to hold exactly 64 characters except the last, between a "-----BEGIN " line and a "-----END " line naming a label such as CERTIFICATE. The RFC accepts CRLF, CR or LF as the line ending; the calculator uses a single line feed after every line, both boundary lines included, as in the RFC's strict format. A CERTIFICATE label adds 28 bytes for the BEGIN line and 26 for the END line:
PEM = padded + ⌈padded ÷ 64⌉ + armor
A data URI, defined in RFC 2397, has the form data:[mediatype][;base64],data. The prefix for a PNG, "data:image/png;base64,", is 22 bytes. With no media type it shrinks to "data:;base64,", 13 bytes, and the RFC says the type then defaults to text/plain;charset=US-ASCII.
The overhead is the encoded size minus the original. Multiplied by the requests each month, it gives the extra transfer, shown in decimal units with 1 GB = 1,000,000,000 bytes, the convention the data storage converter labels GB rather than GiB.
Worked example: 100 KB sent a million times
The default 100 KB is 100,000 bytes. That is 33,333 full 3-byte groups and one byte left over, so the encoder writes 33,334 groups of 4 characters, 133,336 bytes, with "==" at the end. The overhead is 33,336 bytes, 33.34%, which sits 0.01 points above the 33.33% of a pure 4:3 ratio. Sent 1,000,000 times a month, those extra bytes add up to 33.336 GB.
The table shows the other encodings of the same file:
- base64url drops the two "=" and takes 133,334 bytes, 33.33%.
- MIME splits the 133,336 characters into 1,755 lines, adding 3,510 bytes of CRLF for 136,846 bytes, 36.85%, or 36.846 GB a month.
- PEM with a CERTIFICATE label needs 2,084 lines, so 2,084 line feeds and the 54 bytes of BEGIN and END lines bring it to 135,474 bytes, 35.47%.
- A PNG data URI adds its 22-byte prefix for 133,358 bytes, 33.36%.
On large inputs the line breaks settle at a fixed rate. A 1,000 MB attachment grows by 36.84% under MIME, two bytes for every 76 characters on top of the 4:3, and by 35.42% as PEM. To see how long the extra bytes take to arrive, enter the encoded size in the download time calculator, and if a cloud provider bills the transfer by the gigabyte, the cloud egress cost calculator prices it.
Where Base64 came from
The encoding began in secure email. RFC 989, John Linn's February 1987 specification for Privacy Enhanced Mail, proposed "a 64-character subset of International Alphabet IA5" that turned strings of 3 arbitrary 8-bit characters into 4 encoded characters, with "=" as padding and a second special character, "*", marking text left out of encryption. Its output was cut into lines of 64 printable characters. RFC 1113 replaced it in August 1989, keeping every line except the last at exactly 64 characters, a length it said is "guaranteed to satisfy SMTP's 1000-character transmitted line length limit." RFC 1421 carried the same rule in February 1993.
MIME borrowed it. RFC 1341, by Nathaniel Borenstein and Ned Freed in June 1992, adapted the Base64 transfer encoding from RFC 1113 with one change, dropping the "*" mechanism, and wrote that encoded data "are consistently only about 33 percent larger than the unencoded data." It set the 76-character line limit. RFC 2045 restated both in November 1996 and called the encoding "virtually identical" to PEM's in RFC 1421. That "about 33 percent" leaves out the line breaks the same section requires, which is why an attachment grows by nearly 37%.
Base64 got a specification of its own in RFC 3548, by Simon Josefsson, in July 2003, replaced by RFC 4648 in October 2006. RFC 4648 explains that the MIME and PEM line limits "are both due to limits within SMTP" and forbids line feeds in Base64 unless the referring specification asks for them. Larry Masinter's RFC 2397 defined the data URL scheme in August 1998, from an idea first proposed in August 1995, and warned that it "is only useful for short values." RFC 7468, by Josefsson and Sean Leonard in April 2015, wrote down the de facto PEM-style format that certificate and key libraries still use, tracing it back to RFC 1421.
The overhead still shapes mail limits. Exchange Online's default message limits are 35 MB for sending and 36 MB for receiving, and administrators can raise them as far as 150 MB. Messages that never leave Microsoft's datacenters can use all 150 MB, but those routed outside are "subject to an additional 33% translation encoding increase," so Microsoft gives them a maximum of 112 MB. Microsoft doesn't define its megabyte. Taking MB as 1,000,000 bytes, 112 MB of padded Base64 is 149,333,336 bytes, under 150 MB, while the same data with MIME's line breaks is 153,263,162 bytes, over it. With binary megabytes the result is the same.
Assumptions and limits
Sizes are rounded to a whole byte. KB and MB are decimal, while KiB and MiB are 1,024 and 1,048,576 bytes. The MIME figure covers the encoded body only, not headers or multipart boundaries, and the PEM figure assumes no explanatory text around the boundaries; with CRLF line endings a PEM file grows by one more byte per line. The monthly figure counts only the overhead, before any HTTP compression; the bandwidth calculator shows how much a connection moves in an hour or a day for comparison. Sizes are capped at 1 TB and requests at 1,000,000,000 a month.
Frequently asked questions
How much bigger does Base64 make a file?
A third bigger, plus a little. Base64 writes every 3 bytes as 4 characters, so the floor is 33.33%, and padding rounds the last group up to 4 characters. A 100 KB file becomes 133,336 bytes, an overhead of 33,336 bytes or 33.34%. Line breaks add more: as a MIME email attachment the same file takes 136,846 bytes, 36.85% more than the original.
How do I calculate the Base64 length of n bytes?
With padding, multiply the number of 3-byte groups, rounded up, by 4: 4 × ceil(n ÷ 3). Without padding, as in base64url for JSON Web Tokens, the length is ceil(4n ÷ 3). The 32-byte HMAC SHA-256 signature in RFC 7515's example takes 44 characters padded and 43 as base64url, which is the length of the signature shown in that RFC.
Why does an email attachment grow by more than 33 percent?
MIME limits Base64 lines to 76 characters, and every line of a mail message ends in a two-byte CRLF. That adds 2 bytes for every 76 characters, so a large attachment grows by 36.84% rather than 33.33%. Exchange Online allows messages of up to 150 MB that stay inside Microsoft's datacenters but gives those routed outside a maximum of 112 MB, citing a 33% encoding increase.
What is the difference between Base64 and base64url?
Only two characters of the alphabet and, usually, the padding. base64url uses minus and underscore where standard Base64 uses plus and slash, so the text is safe in URLs and filenames. RFC 4648 lets a format drop the equals-sign padding when the length is known, and JSON Web Signatures do, so base64url output is up to two characters shorter.
How large is a certificate in PEM format?
PEM wraps the Base64 at 64 characters per line and adds a BEGIN and an END line. With line feeds, a 1,200-byte DER certificate becomes 1,600 Base64 characters in 25 lines, plus 25 line feeds and 54 bytes of BEGIN CERTIFICATE and END CERTIFICATE lines, 1,679 bytes in all, 39.92% more than the binary file.
Sources
- RFC 4648: The Base16, Base32, and Base64 Data Encodings, IETF, 2006
- RFC 3548: The Base16, Base32, and Base64 Data Encodings, IETF, 2003
- RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, IETF, 1996
- RFC 2046: Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types, IETF, 1996
- RFC 1341: MIME (Multipurpose Internet Mail Extensions), IETF, 1992
- RFC 989: Privacy Enhancement for Internet Electronic Mail: Part I, IETF, 1987
- RFC 1113: Privacy Enhancement for Internet Electronic Mail: Part I, IETF, 1989
- RFC 1421: Privacy Enhancement for Internet Electronic Mail: Part I, IETF, 1993
- RFC 7468: Textual Encodings of PKIX, PKCS, and CMS Structures, IETF, 2015
- RFC 2397: The "data" URL scheme, IETF, 1998
- RFC 5321: Simple Mail Transfer Protocol, IETF, 2008
- RFC 7515: JSON Web Signature (JWS), IETF, 2015
- Exchange Online limits, Microsoft Learn, 2026