Cipher Utility

Base64 Decode and Encode

E-01

Base64 to text and text to Base64, with UTF-8 and URL-safe output. Runs in your browser; nothing is sent anywhere.

Type:

How Base64 works

  1. Turn the text into bytes.
  2. Take 3 bytes, 24 bits.
  3. Cut them into four 6-bit groups.
  4. Look up each group, 0 to 63, in the alphabet.
  5. Pad a short last group with =.

Worked example

Hi! = ?

Three bytes, cut into 6-bit groups:

010010 000110 100100 100001

Values 18, 6, 36, 33:

Hi! = SGkh

Further reading

Cipher Utility reference card Catalog no. E-01

What Base64 is

Base64 writes any data, text or binary, using only 64 safe characters: A to Z, a to z, 0 to 9, + and /. Those characters pass unchanged through email, JSON, URLs and other places that would damage raw bytes. Decoding turns them back into the original bytes.

The encoder first converts your text to UTF-8, so accented letters and emoji survive the round trip.

Cipher Utility runs in your browser. Q2lwaGVyIFV0aWxpdHkgcnVucyBpbiB5b3VyIGJyb3dzZXIu

The Base64 alphabet

ValuesCharacters
0 to 25A to Z
26 to 51a to z
52 to 610 to 9
62+ (URL-safe: -)
63/ (URL-safe: _)
Padding=

Padding with =

Base64 handles 3 bytes at a time. If the data does not divide evenly, the last group is padded:

Hi! → SGkh 3 bytes, no padding Hi → SGk= 2 bytes, one = H → SA== 1 byte, two =

Some systems leave the padding off. The decoder here adds it back, so both forms work.

URL-safe Base64

The + and / characters have special meanings in URLs and file names, so a URL-safe variant uses - and _ instead and usually drops the = padding. JSON Web Tokens use it, for example. Choose URL under Type when encoding. The decoder accepts both variants without any setting.

Standard: SGk/Pg== URL-safe: SGk_Pg

Where Base64 is used

Email attachments are sent as Base64 inside the message. Data URLs put small images straight into HTML or CSS (data:image/png;base64,...). HTTP Basic authentication sends user:pass as dXNlcjpwYXNz, which is why it must only be used over HTTPS: the password is merely encoded. Our article on why Base64 is not encryption has more examples.

Questions about Base64

How do I decode Base64?

Paste the Base64 string into the box above with Base64 to Text selected. The decoder ignores spaces and line breaks, accepts the URL-safe variant with - and _, and adds missing = padding.

Is Base64 encryption?

No. Base64 has no key, and anyone can decode it in one step. It only makes binary data safe to send as text. If something must stay private, encrypt it first.

Why does Base64 end with = or ==?

Base64 works on groups of 3 bytes. When the last group has only 1 or 2 bytes, = signs fill the output up to a multiple of 4 characters. One = means the last group had 2 bytes, == means it had 1.

Why is Base64 longer than the original?

Every 3 bytes become 4 characters, so Base64 is about 33% larger than the data it encodes, plus any padding.

Why does my Base64 decode to unreadable symbols?

The data is probably not text. Base64 often carries images, PDFs, compressed files or encrypted data. The decoder here shows text only and tells you when the bytes are not valid UTF-8.

Is my data sent to a server?

No. Encoding and decoding run in your browser with JavaScript, and nothing you paste leaves your device.