Skip to content
All tools›Encoders / Cryptography›Base 64 Encoder & Decoder

Base 64 Encoder & Decoder

Encodes or decodes a string or a binary file so that it conforms to the Base64 Data Encodings specification (RFC 4648).

Loading tool...

Base64 Encoding Explained

What is Base64 and why is it used?

Base64 is a way of representing arbitrary binary data using only 64 printable ASCII characters. It is specified in RFC 4648. Base64 is not encryption: it hides nothing.

How does it work?

The input is processed three bytes at a time. Three bytes (24 bits) are split into four groups of 6 bits, and each 6-bit value (0-63) is looked up in the alphabet. So every 3 input bytes become 4 output characters.

The Base64 alphabet

Value Char Value Char
0-25 A - Z 26-51 a - z
52-61 0 - 9 62/63 + / / (standard), - / _ (URL-safe)

Padding

When input length is not a multiple of 3, padding with = makes the encoded length a multiple of 4.

Common uses

  • E-mail attachments (MIME)
  • HTTP Basic authentication
  • JSON Web Tokens (base64url)
  • Certificates and keys in PEM format
  • Data URIs in CSS and HTML
---