Man page for base64


base64 – stand-alone encoder and decoder for base64


base64 [ -d ] [ filename ]
base64 -e [ -c width ] [ filename ]


base64 is a command-line utility for encoding and decoding the ‘base64’ encoding.

This encoding, defined in RFC 2045, is primarily used to encode binary attachments in MIME e-mail, but is widely used in many other applications as well. For example, the ‘Content-MD5’ mail header contains a small piece of base64; SSH private keys are generally stored as base64-encoded blobs; and so on.

Other utilities, such as munpack, exist which will take an entire MIME-encoded message, identify the base64-encoded subparts, and decode them. However, these utilities will not help you if you need to inspect a Content-MD5 header or an SSH private key.

base64 is a very simple stand-alone encoder and decoder for the base64 format alone. It does not try to understand MIME headers or anything other than raw data.


By default (if neither -d or -e is supplied), base64 operates in decode mode.

Places base64 into decode mode. In this mode, it will read from standard input or the supplied file name, ignore all characters that are not part of the base64 alphabet, decode the ones that are, and output the decoded data on standard output.
Places base64 into encode mode. In this mode, it will read binary data from standard input or the supplied file name, encode it as base64, and output the encoded data on standard output.
-c width
If base64 is operating in encode mode, this controls the number of base64 characters output per line of the encoded file. Normally base64-reading applications do not care about this, so the default of 64 characters per line is perfectly adequate.

The special value 0 will prevent base64 from ever writing a line break in the middle of the data at all.

--hex or --HEX
Switch the encoding from base64 to the trivial hexadecimal encoding, in which each binary byte is encoded as a pair of output hex digits. Output hex digits are in lower- or uppercase depending on whether you specified --hex or --HEX. Either case is tolerated on input, no matter which operation you specified.


base64 is free software, distributed under the MIT licence. Type base64 --licence to see the full licence text.

[base64 version 20230903.c678881]