Encode text or files to Base64 or decode Base64 back to text. Supports image preview, data URL output, and one-click direction swap — nothing sent to a server.
Enter text or a file above and click Encode / Decode
Base64 is a binary-to-text encoding scheme standardized under RFC 4648. It translates arbitrary binary data (such as compiled executables, raw images, or cryptographic keys) into an ASCII string representation composed of 64 printable characters. This enables binary transmission across text-only protocols like HTTP headers, email (MIME), and JSON payloads without data corruption.
Base64 maps consecutive 24-bit chunks of binary data (3 bytes) into four 6-bit index values:
$$\frac{24 \text{ bits}}{6 \text{ bits/char}} = 4 \text{ encoded characters}$$
Because $2^6 = 64$, each 6-bit block maps directly to one character in the Base64 alphabet:
A-Z (indices 0-25), a-z (indices 26-51), 0-9 (indices 52-61), + (index 62), and / (index 63).
| Binary Representation | Hex Bytes | Encoded Base64 Output |
|---|---|---|
01001101 01100001 01101110 | 4D 61 6E ("Man") | TWFu |
01000001 (1 byte) | 41 ("A") | QQ== (padded with two = signs) |
01000001 01000010 (2 bytes) | 41 42 ("AB") | QUI= (padded with one = sign) |
Base64 increases raw payload size by approximately 33% ($4 / 3 = 1.333$).
Standard Base64 contains + and /, which carry special reserved meanings in URL query parameters.
URL-Safe Base64 substitutes - for + and _ for /, frequently omitting trailing = padding characters.
JavaScript
// Browser & Node.js
function utf8ToBase64(str) {
return btoa(unescape(encodeURIComponent(str)));
}
function base64ToUtf8(b64) {
return decodeURIComponent(escape(atob(b64)));
}
Python
import base64
raw_bytes = b"BestToolOnline Developer Suite"
encoded = base64.b64encode(raw_bytes).decode("ascii")
print("Base64:", encoded)
decoded = base64.b64decode(encoded).decode("utf-8")
print("Decoded:", decoded)
This website and utility are provided for general informational, calculation, and educational purposes only. Always verify critical computation outputs prior to professional deployment or financial use. See our Terms of Service and Privacy Policy for full governance details.