What is Base64?
Learn about Base64 encoding: how it works, why it's used, and its applications in modern web development.
Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses 64 different characters (A-Z, a-z, 0-9, +, /) to represent data, making it safe for transmission over text-based protocols like HTTP, email, and JSON.
Original text: "Hello World!"
Base64 encoded: SGVsbG8gV29ybGQh
Text Safe
Converts binary data to safe ASCII text format
Web Compatible
Works in URLs, JSON, XML and web protocols
Universal Standard
Supported by all programming languages and platforms
1. Binary Data
Input data is converted to binary representation (8-bit bytes)
2. Group in 6-bits
Binary data is divided into 6-bit groups (64 possible values)
3. Map to Characters
Each 6-bit value maps to one of 64 ASCII characters
Base64 Character Set:
Email Attachments
Encode binary files in email messages (MIME)
PDF, images, documents in emailWeb APIs
Send binary data through JSON REST APIs
Image uploads, file transfers via APIData URLs
Embed images directly in HTML/CSS
data:image/png;base64,iVBORw0KGgoA...Configuration Files
Store binary data in text-based config files
Certificates, keys in YAML/JSON- Safe for text-based transmission
- Universally supported
- No special characters in output
- Preserves binary data integrity
- 33% size increase over binary
- Not suitable for large files
- Encoding/decoding overhead
- Not human-readable