Understanding Base64 Encoding and Decoding
Base64 encoding is a fundamental technique in web development for converting binary data into a text format that can be safely transmitted over text-based protocols. This guide explains how it works and when to use it.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It uses 64 characters (A-Z, a-z, 0-9, +, /) plus the = character for padding.
How Base64 Works
- Binary data is divided into groups of 3 bytes (24 bits)
- Each group is split into 4 chunks of 6 bits
- Each 6-bit value is mapped to a Base64 character
Common Use Cases
- Data URIs: Embedding images in CSS/HTML (
data:image/png;base64,...) - Email Attachments: MIME encoding for email
- API Authentication: HTTP Basic Auth headers
- JSON Web Tokens (JWT): Token encoding
- Certificate Encoding: PEM files
UTF-8 Support
Base64 works with binary data, so encoding UTF-8 text requires special handling. Our Base64 Encoder automatically handles UTF-8 encoding and decoding correctly.
✨ Try Our Free Base64 Encoder/Decoder
Encode and decode Base64 strings with UTF-8 support.
Open Base64 Tool →