What Is Base64 Encoding?
Base64 is a binary-to-text encoding method that converts binary data into a string of ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) to represent data, making it safe to transmit through text-based systems like email, JSON, and URLs.
Why Do We Need Base64?
Many systems only support text data. When you need to send binary data (like images, files, or encrypted content) through these systems, Base64 converts it to safe text format. Common use cases:
- Embedding images in HTML/CSS using data URIs
- Sending file attachments in emails (MIME encoding)
- Encoding API tokens and authentication credentials
- Storing binary data in JSON or XML
- JWT tokens use Base64 for header and payload encoding
How Base64 Works
Base64 takes every 3 bytes (24 bits) of input and converts them into 4 ASCII characters (6 bits each). This means Base64 output is always ~33% larger than the input.
Example:
- Input: "Hello" (5 bytes)
- Base64: "SGVsbG8=" (8 characters)
The "=" padding characters ensure the output length is always a multiple of 4.
How to Encode/Decode Base64
Base64 in JavaScript
// Encode
const encoded = btoa("Hello World");
// Result: "SGVsbG8gV29ybGQ="
// Decode
const decoded = atob("SGVsbG8gV29ybGQ=");
// Result: "Hello World"
Important Notes
- Base64 is NOT encryption — anyone can decode it
- Never use Base64 alone to protect sensitive data
- Base64 increases data size by ~33%
- For large files, use direct file transfer instead of Base64 encoding
Free Base64 Encoder/Decoder
Try our Base64 Encoder/Decoder — it works entirely in your browser with zero server uploads. Encode and decode text instantly.