Cipher Table

Base64 encode and decode

Turn any text into a string of plain letters and digits that survives email, URLs and config files, and turn it back again. Nothing leaves your device.

What Base64 is for

Many systems were built to carry text, and only a limited range of text at that. Early email could reliably carry only 7-bit ASCII characters; anything else might be mangled on the way. So how do you email a photograph?

You re-write the raw bytes using only characters that every system handles safely. Base64 uses 64 of them: A–Z, a–z, 0–9, + and /.

You will meet it in:

  • Email attachments, which is where it was standardised, in the MIME specification.
  • Data URLs, which embed small images directly in a web page.
  • JSON Web Tokens and other credentials passed around by web apps.
  • Configuration files, certificates and SSH keys.

How it works

Sixty-four possibilities is exactly six bits’ worth. So Base64 takes the input three bytes (24 bits) at a time and re-cuts it into four 6-bit pieces. Each piece is a number from 0 to 63, which is looked up in the alphabet.

Text      M        a        n
Bytes     01001101 01100001 01101110
Regroup   010011 010110 000101 101110
Values    19     22     5      46
Base64    T      W      F      u

So Man becomes TWFu. If the input runs out before a group of three is complete, the output is filled out with =.

Recognising it

Base64 has a distinctive look: a solid block of mixed upper-case, lower-case and digits, no spaces, a length that is a multiple of four, and often one or two = at the end. Text that begins eyJ is very often a JSON object, because {" encodes to those characters.

If you find Base64 in a puzzle and it decodes to something still unreadable, there may be another layer underneath. Take the output to the cipher identifier.

Questions people ask

Is Base64 encryption?

No. There is no key and anyone can reverse it instantly. Base64 makes data safe to transport, not safe from being read. Never treat a Base64-encoded password or token as protected.

Why does Base64 end with equals signs?

Base64 works on groups of three bytes. If the data length isn't a multiple of three, the final group is padded, and "=" marks the padding. One "=" means two real bytes in the last group; "==" means one.

How much bigger does Base64 make things?

About a third. Every three bytes of input become four characters of output.

What is URL-safe Base64?

Standard Base64 uses "+" and "/", which have special meanings in web addresses. The URL-safe variant uses "-" and "_" instead and often drops the "=" padding. The decoder here accepts both forms.

Is it safe to paste sensitive data here?

The conversion happens entirely in your browser's own JavaScript; this site has no server that receives your text. That said, for real secrets such as live credentials, the most careful habit is to use a tool on your own machine.