Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It's used everywhere in web development — from embedding images in HTML to encoding API authentication tokens.
Why Base64 Exists
Many systems (email, URLs, JSON) are designed to handle text, not raw binary data. When you need to send binary content (images, files, encrypted data) through these text-based channels, Base64 converts it into safe, printable characters.
How It Works
Base64 takes every 3 bytes of input and converts them into 4 ASCII characters from this set:
A-Z, a-z, 0-9, +, / (with = for padding)
This means Base64 output is always about 33% larger than the original data.
Common Uses
1. Data URIs (Embedding Images in HTML/CSS)
<img src="data:image/png;base64,iVBORw0KGgo..." />Useful for small icons to avoid extra HTTP requests.
2. API Authentication (Basic Auth)
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=The value is username:password encoded in Base64.
3. JWT Tokens
JWT tokens consist of three Base64URL-encoded parts separated by dots. Decoding them reveals the header, payload, and signature.
4. Email Attachments (MIME)
Email protocols use Base64 to encode file attachments so they travel safely through text-based mail servers.
Base64 vs. Base64URL
| Feature | Base64 | Base64URL |
|---|---|---|
| Characters | A-Z, a-z, 0-9, +, / | A-Z, a-z, 0-9, -, _ |
| Padding | Uses = | Often omitted |
| Safe for URLs | No | Yes |
Base64URL replaces + with - and / with _ to make encoded strings safe for use in URLs and filenames.
Try It
Use our Base64 Encoder/Decoder to quickly encode text to Base64 or decode Base64 strings back to readable text. Everything runs in your browser — no data is sent to any server.