Uuencode and Uudecode

Encode text, hex bytes or files in the classic Unix-to-Unix format, or decode uuencoded blocks from old emails, Usenet archives and scripts back to the original data.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Choose Encode to create a uuencoded block, or Decode to recover the data from one.
  2. Keep the begin and end lines on and enter a file name if the result should work with the uudecode command. Turn them off to get only the data lines.
  3. Type or paste your input, or open a file to encode its bytes.
  4. When decoding, paste the whole block including the begin line if there is one, then copy the result or download it as a file.

What is uuencode?

Uuencode, short for Unix-to-Unix encode, dates from around 1980, when files were copied between Unix machines over UUCP links that only carried text. It turns every 3 bytes into four 6-bit values and adds 32 to each, giving printable characters from the space to the underscore. Because mail systems often stripped trailing spaces, the value zero is written as a backtick (`) instead of a space, as this tool does.

A uuencoded file has a fixed layout:

  • A header line begin 644 name, where 644 is the Unix file mode in octal (owner can read and write, everyone else can read) and name is the file to create.
  • Data lines of up to 45 input bytes. Each starts with a length character (32 plus the byte count, so a full line starts with M) followed by up to 60 encoded characters.
  • A line with a single backtick, meaning zero bytes, and then the line end.

With the length characters and line breaks, the output is about 38% larger than the input.

Uuencode today

Before MIME, uuencode was the usual way to send programs and images by email and to post them on Usenet. MIME Base64 replaced it during the 1990s: uuencode had no way to declare a content type, several incompatible variants existed, and some of its punctuation characters were altered by gateways between ASCII and EBCDIC systems, which is why xxencode was created.

You still meet uuencoded data in mail and news archives, older shell scripts and legacy systems. For new work, use Base64, or File to Base64 for whole files.

Uuencode on the command line and in Python

# Shell (GNU sharutils): input file, then the name for the begin line
uuencode photo.jpg photo.jpg > photo.uu
uudecode photo.uu

# Python: one line of up to 45 bytes at a time
import binascii
line = binascii.b2a_uu(b'hello', backtick=True)
binascii.a2b_uu(line)          # b'hello'

Python's old uu module was removed in Python 3.13, but the binascii functions remain.

Specification

AlphabetASCII 32 to 96 (space to `)
Output sizeAbout 137% including line prefixes
PaddingLines of up to 45 bytes
StandardPOSIX uuencode
Case sensitiveYes

Examples

Input (UTF-8)Output
Hello, World!begin 644 data.bin -2&5L;&\L(%=O<FQD(0`` ` end
Base64.isbegin 644 data.bin )0F%S938T+FES ` end
你好begin 644 data.bin &Y+V@Y:6] ` end

Frequently asked questions

Why does uuencoded text contain backticks?

The value zero would map to a space, and spaces at the end of lines were often lost in transit. Many encoders, including this one, write a backtick instead. The decoder accepts both.

What does begin 644 mean?

It starts the encoded block. 644 is the Unix permission mode for the restored file (read and write for the owner, read for everyone else), and the word after it is the file name that uudecode will create. You can set the name in the options.

Can I decode uuencode without the begin line?

Yes. If there is no begin line, every line is decoded as data. If there is one, decoding starts after it and stops at the end line, so text around the block, such as an email body, is skipped. Trailing spaces removed by mail software are restored automatically.

Is uuencode the same as Base64?

No. Both turn 3 bytes into 4 characters, but uuencode uses a different character range, a length character on each line and begin and end lines. Base64 output cannot be decoded as uuencode or the other way round.