Base64 Encoder & Decoder

Convert standard text into Base64 encoded strings, or decode existing Base64 back to readable text.

Plain Text (UTF-8)
Base64 String

Understanding Base64 Encoding

Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format. It translates data into a radix-64 representation, which means it uses exactly 64 characters from the standard ASCII alphabet (A-Z, a-z, 0-9, +, and /). The equals sign (=) is also used, but strictly as a padding character at the end of the string.

Why Do We Need Base64?

Computers process data in binary (0s and 1s). Text is easy to transmit across the internet because protocols like HTTP and SMTP were originally designed to handle standard ASCII characters. However, when you try to send raw binary data (like an image, a compiled executable, or a PDF file) over these text-based protocols, certain byte sequences are misinterpreted as control characters (like "end of line" or "end of file"), causing data corruption.

Base64 solves this by taking the raw binary data and converting it into "safe" printable text characters. A classic example is embedding a small image directly into a CSS file or HTML document using a Data URI:

<img src="data:image/png;base64,iVBORw0KGgoAAA..." alt="Embedded Image" />

How the Base64 Algorithm Works

The encoding process follows a very specific mathematical algorithm:

  1. Byte Grouping: The algorithm takes the input data (whether text or binary) and divides it into groups of 3 bytes (24 bits total).
  2. Bit Splitting: Those 24 bits are then split into 4 groups of 6 bits each.
  3. Index Mapping: Each 6-bit group represents a number between 0 and 63. This number is used as an index to look up a character in the standard Base64 alphabet table. (For example, 0 = 'A', 26 = 'a', 52 = '0', 62 = '+', 63 = '/').
  4. Padding: If the original data is not a multiple of 3 bytes, the algorithm adds one or two padding characters (=) to the end of the output string to ensure the final Base64 string length is a multiple of 4.

Base64 is NOT Encryption

Crucial Security Warning: A common and dangerous misconception among junior developers is that Base64 provides security. Base64 is encoding, not encryption. It does not use a key, and anyone who intercepts a Base64 string can instantly decode it back to its original form using a tool exactly like the one on this page. Never use Base64 to "hide" passwords, API keys, or sensitive user data in your codebase.