How it works

Base64 takes the data three bytes at a time and writes each group as four characters from its alphabet. When the data does not divide evenly, the result is padded with one or two equals signs (=).

Because every 3 bytes become 4 characters, the encoded text is about 33% larger than the original.

Where you will see it

Base64 appears in many places.

  • Email attachments
  • Data URLs that embed small images in HTML or CSS
  • JSON Web Tokens, which use a URL-safe variant
  • HTTP Basic authentication headers
  • API responses that carry files inside JSON

It is not encryption

Anyone can decode Base64 in a second, so it gives no protection. Do not use it to hide passwords or personal data. Use real encryption for that.

Text and Unicode

Letters outside basic English, such as accented characters and emoji, must first be turned into bytes using UTF-8 before encoding. A good tool does this for you so that decoding returns exactly the text you started with.

Try it

The Base64 Encoder and Decoder converts text both ways in your browser, with Unicode support.

Common questions

Frequently asked questions

Why does Base64 end with equals signs?

They are padding that fills the last group when the data length is not a multiple of three bytes.

Is Base64 secure?

No. It is an encoding, not encryption.

What is URL-safe Base64?

A variant that replaces plus and slash with dash and underscore so the text can be placed in URLs.

Keep reading

More guides