How much larger does UUENCODE make binary files?

I remember reading somewhere that any binary files sent attached to an email must be first UUENCODEd, which makes the file sizes considerably larger, hence why it's better to send files via some other direct-transfer means such FTP, Skype, etc.

How much larger will UUENCODE make my binary files?


Short answer:

The size of the uuencoded file will be about 35% bigger than the original file.


Long answer:

Uuencode files look like this:

begin 600 filename
*"F9O;R!B87(*"@``
`
end              
  • That is 7 bytes for begin, three for the permissions, two for the separating spaces.
  • X bytes for the filename (depending on the name)
  • Then the actual encoded data. Every 6 bits get mapped to a 8 bits (with the result all printable ASCII chars). This increases the size to 8/6, or 1⅓ times the original size.
  • The result is then broken into lines of 65 chars so the result would on an 80 char. wide screen. This adds an extra newline per 65 chars. Thus increasing file size by 1/65th
  • Finally 3 bytes for end

Thus we get: 13 bytes, plus filename length, plus 1 68/195th of the original file size.

(The 68/195th is 1⅓ plus 1/65, or 1 65/195 plus 3/195. This is very close to 35%, which is why the rule of thumb is that 'size increases by a good third).


Common modern email clients will use base64, which will make the file about 35% larger, but only within the email.

These days, base64 is normally used instead. Each byte of the original binary contains 8 bits. Base64 can store the equivalent of 6 bits of original data within each encoded byte. So encoded size is 8/6ths that of the original:

8 / 6 = 1.33... = 133% = 33% more

And then line breaks are added which adds another couple of percent.

Of course, once the file is decoded to be saved to the recipient's file system, the decoded file will be identical to the original.