Base64 Encoder & Decoder
Convert plain text into Base64 encoded format or decode Base64 string back into readable text.
Result
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts arbitrary binary data into a string of printable ASCII characters. It represents binary data using only 64 characters: uppercase letters A–Z, lowercase letters a–z, digits 0–9, plus (+), slash (/), and the padding character equals (=). The name "Base64" comes from the 64-character alphabet used.
Base64 is not encryption — it is simply a representation format. Base64-encoded data is trivially decoded by anyone. Do not use it to protect sensitive data. Use it to safely transport binary data through channels designed for text.
How Base64 Encoding Works
The algorithm works on groups of 3 bytes (24 bits) at a time, converting them into 4 Base64 characters. Since each Base64 character represents 6 bits (2⁶ = 64), four 6-bit groups cover the same 24 bits as three 8-bit bytes. This results in a ~33% size increase — every 3 bytes of input becomes 4 characters of output.
If the input length is not divisible by 3, padding characters (=) are appended to make the output length a multiple of 4. One = means 1 byte of padding was needed; two == means 2 bytes of padding.
Example: The ASCII string "Hi" encodes to SGk= in Base64. "Man" encodes to TWFu (no padding needed as it's exactly 3 bytes).
Common Real-World Uses of Base64
- Email Attachments (MIME): The MIME standard uses Base64 to encode binary attachments (images, PDFs, executables) for transmission over email protocols (SMTP) that were originally designed for 7-bit ASCII text only. Your email client handles this transparently when you attach a file.
- Embedding Images in HTML/CSS: Small images (icons, logos) can be embedded directly into HTML or CSS as Base64-encoded Data URLs:
src="data:image/png;base64,iVBORw0KGgo...". This eliminates an extra HTTP request but increases file size. - JSON Web Tokens (JWT): JWTs encode the header and payload sections in Base64Url format (a URL-safe variant of Base64 using
-and_instead of+and/). This is how authentication tokens are passed in web APIs. - HTTP Basic Authentication: The HTTP Basic Auth scheme sends credentials as
Authorization: Basic dXNlcjpwYXNz, where the value is the Base64 encoding ofusername:password. - Storing Binary Data in Databases: Some databases (or APIs) don't support raw binary storage. Base64 allows binary data (images, files) to be stored as text strings in JSON or XML fields.
Base64 vs Base64Url: What's the Difference?
Standard Base64 uses + and / characters which have special meaning in URLs. Base64Url replaces these with - and _ respectively, and omits trailing = padding. This makes it safe to use directly in URL query parameters and HTTP headers without URL-encoding. JWT tokens use Base64Url encoding exclusively.
Is Base64 the same as encryption?
No. Base64 is an encoding scheme, not encryption. Anyone can decode a Base64 string instantly — there is no key or secret involved. If you need to protect data, use proper encryption algorithms like AES-256 (symmetric) or RSA (asymmetric). Base64 is only used to make binary data safe for text-based transmission, not to hide its content.
Why does Base64 increase data size by ~33%?
Because every 3 bytes (24 bits) of input is represented as 4 Base64 characters (each representing 6 bits). So 3 bytes become 4 characters — a 33.3% overhead. For large files like images or videos, this size increase is one reason Base64 inline embedding is generally only recommended for small assets (under a few kilobytes).