base64

Linux · Text · reference only

What it does

Encodes data as Base64 or decodes it. It turns binary content into text that can be copied or sent by email.

Syntax

base64 [opciones] [fichero]

Options and parameters

  • -d

    Decodes instead of encoding.

  • -w columnas

    Wraps the output at that width; 0 disables wrapping.

  • -i

    When decoding, ignores characters that are not part of the Base64 alphabet.

  • --help

    Shows help and exits.

  • --version

    Shows the version and exits.

Usage examples

  • echo -n hola | base64

    Encodes hola with no trailing newline and returns aG9sYQ==.

  • echo aG9sYQ== | base64 -d

    Decodes the text and returns hola.

  • base64 -w 0 imagen.png

    Encodes the file on a single line, with no wrapping.

  • base64 -d datos.b64 > datos.bin

    Recovers a binary file from its Base64 version.

Notes and common mistakes

  • Base64 is not encryption: anyone can decode it, so it does not protect sensitive information.
  • With echo without -n the trailing newline is encoded too.

Related commands