What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme. It translates binary data into a set of 64 characters, making it safe to transmit data over text-based protocols like HTML, email, or URLs without losing any information.
In this guide, we'll explain how Base64 works and when to use it in your applications.
The Base64 Index Table
Base64 uses the following alphabet characters:
- Uppercase letters
A-Z(values 0–25) - Lowercase letters
a-z(values 26–51) - Numeric digits
0-9(values 52–61) - Plus symbol
+(value 62) and slash/(value 63)
For padding, the equals sign = is appended at the end of the string to align the final chunk of data.
Why Do We Need Base64?
Historically, many communication channels (like email protocols) were designed to transmit only 7-bit ASCII text. Binary files (like images, zip files, or executables) contain 8-bit bytes, which can get corrupted when sent over these channels.
By encoding binary streams into Base64 ASCII characters, we ensure the data arrives safely and unchanged at its destination.
Base64 Encoder / Decoder
Encode plain text to Base64 format or decode Base64 back to plain text.
Common Web Use Cases
Base64 is commonly used for:
- Data URIs: Embedding small images directly in CSS stylesheets or HTML
srcattributes:
```html
<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />
```
- Authentication Headers: Basic Auth headers send credentials encoded as Base64 strings.
- API Payloads: Transmitting small binary files inside JSON objects.