Processed entirely in your browser. Your data is never sent to our servers.
Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using a set of 64 ASCII characters: A-Z, a-z, 0-9, +, and /, with = used for padding. Base64 is one of the most widely used encoding formats on the web, found in emails, data URIs, APIs, and configuration files.
The primary purpose of Base64 is to allow binary data to be safely transmitted through text-based systems that may not handle raw binary correctly — such as email (MIME), JSON payloads, HTML attributes, and URL parameters.
Base64 encoding works by dividing the input data into groups of 3 bytes (24 bits). Each group is then split into four 6-bit values, and each 6-bit value is mapped to one of the 64 characters in the Base64 alphabet. If the input length is not a multiple of 3, the output is padded with one or two = characters.
Here is how the string Man is converted to its Base64 representation TWFu:
| Step | M | a | n |
|---|---|---|---|
| ASCII value | 77 | 97 | 110 |
| Binary (8 bits) | 01001101 | 01100001 | 01101110 |
The 24 bits (010011010110000101101110) are regrouped into four 6-bit values:
| 6-bit group | 010011 | 010110 | 000101 | 101110 |
|---|---|---|---|---|
| Decimal value | 19 | 22 | 5 | 46 |
| Base64 character | T | W | F | u |
Result: Man → TWFu. When the input length is not a multiple of 3, padding (=) is added: Ma → TWE= and M → TQ==.
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| 6 | G | 22 | W | 38 | m | 54 | 2 |
| 7 | H | 23 | X | 39 | n | 55 | 3 |
| 8 | I | 24 | Y | 40 | o | 56 | 4 |
| 9 | J | 25 | Z | 41 | p | 57 | 5 |
| 10 | K | 26 | a | 42 | q | 58 | 6 |
| 11 | L | 27 | b | 43 | r | 59 | 7 |
| 12 | M | 28 | c | 44 | s | 60 | 8 |
| 13 | N | 29 | d | 45 | t | 61 | 9 |
| 14 | O | 30 | e | 46 | u | 62 | + |
| 15 | P | 31 | f | 47 | v | 63 | / |
The Base64URL encoding (also defined in RFC 4648, Section 5) is a URL-safe variant that replaces + with - and / with _. It also typically omits the = padding characters. Base64URL is safe for use in URLs and filenames without percent-encoding.
Base64URL is used in JSON Web Tokens (JWT), URL parameters, and filenames where standard Base64 characters would need to be percent-encoded. If you are working with JWT tokens, try our JWT Decoder & Encoder tool.
data:[type];base64,[data].username:password in Base64.JavaScript provides built-in btoa() and atob() functions for Base64 encoding and decoding. For UTF-8 strings, use TextEncoder and TextDecoder to handle multi-byte characters correctly.
// Encode
const encoded = btoa('Hello, World!'); // "SGVsbG8sIFdvcmxkIQ=="
// Decode
const decoded = atob('SGVsbG8sIFdvcmxkIQ=='); // "Hello, World!"
// UTF-8 safe encode (handles emoji, CJK, etc.)
const utf8Encode = btoa(String.fromCharCode(
...new TextEncoder().encode('Hello ')
));
// UTF-8 safe decode
const bytes = Uint8Array.from(atob(encoded), c => c.charCodeAt(0));
const utf8Decode = new TextDecoder().decode(bytes);
Python's base64 module provides b64encode() and b64decode(), plus urlsafe_b64encode() for URL-safe Base64.
import base64
# Encode
encoded = base64.b64encode(b'Hello, World!') # b'SGVsbG8sIFdvcmxkIQ=='
# Decode
decoded = base64.b64decode(b'SGVsbG8sIFdvcmxkIQ==') # b'Hello, World!'
# URL-safe variant (replaces + with - and / with _)
url_safe = base64.urlsafe_b64encode(b'Hello, World!')
# Encode a string (must encode to bytes first)
text = 'Hello'
encoded_str = base64.b64encode(text.encode('utf-8')).decode('ascii')
Java 8+ provides java.util.Base64 with getEncoder(), getDecoder(), getUrlEncoder(), and getMimeEncoder().
import java.util.Base64;
import java.nio.charset.StandardCharsets;
// Encode
String encoded = Base64.getEncoder()
.encodeToString("Hello, World!".getBytes(StandardCharsets.UTF_8));
// "SGVsbG8sIFdvcmxkIQ=="
// Decode
byte[] decoded = Base64.getDecoder().decode("SGVsbG8sIFdvcmxkIQ==");
String text = new String(decoded, StandardCharsets.UTF_8);
// URL-safe encoding
String urlSafe = Base64.getUrlEncoder().withoutPadding()
.encodeToString("Hello, World!".getBytes(StandardCharsets.UTF_8));
// MIME encoding (76-char line wrap)
String mime = Base64.getMimeEncoder()
.encodeToString(largeByteArray);
PHP provides base64_encode() and base64_decode() as built-in functions.
// Encode
$encoded = base64_encode('Hello, World!'); // "SGVsbG8sIFdvcmxkIQ=="
// Decode
$decoded = base64_decode('SGVsbG8sIFdvcmxkIQ=='); // "Hello, World!"
// Strict mode (returns false on invalid characters)
$result = base64_decode($input, true);
if ($result === false) {
echo "Invalid Base64 input";
}
// Encode a file
$fileData = file_get_contents('image.png');
$base64File = base64_encode($fileData);
This tool supports 29 character encodings for Base64 encoding and decoding, allowing you to work with text in virtually any Western, Cyrillic, Greek, Arabic, Hebrew, Thai, or Vietnamese script. Select the appropriate encoding from the dropdown to ensure your text is correctly converted to and from Base64.
Supported encoding families include UTF-8, ASCII, ISO-8859 (Latin-1 through Latin-10), Windows code pages (1250–1258, 874), KOI8-R, KOI8-U, IBM-866, and Macintosh Roman. All encoding and decoding is performed entirely in your browser — no data is sent to any server.
Base64 is not encryption. It is a reversible encoding that provides no security whatsoever. Anyone can decode Base64 data without any key or password. Base64 is designed for data transport and compatibility, not for data protection. If you need to protect sensitive data, use actual encryption algorithms like AES or RSA.
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is commonly used to embed binary data in text-based formats like JSON, XML, HTML, and email. Base64 increases the data size by approximately 33%.
It depends on the tool. This Base64 decoder processes everything entirely in your browser using client-side JavaScript. Your data is never sent to any server. However, you should avoid pasting sensitive data into tools that send data to a backend. Always check whether a tool is client-side only before pasting sensitive data.
Standard Base64 uses + and / as the 63rd and 64th characters, with = for padding. Base64URL (defined in RFC 4648) replaces + with - and / with _, and typically omits padding. Base64URL is safe for use in URLs and filenames without percent-encoding.
No. Base64 is an encoding, not encryption. It does not provide any security — anyone can decode Base64 data without a key. It is designed for data transport, not data protection. Never use Base64 to hide sensitive information.
Base64 encodes every 3 bytes of binary data into 4 ASCII characters. This results in a 33% size increase (4/3 ratio). The overhead is the trade-off for being able to safely transmit binary data through text-only channels.
A data URI (data URL) embeds Base64-encoded data directly in HTML or CSS using the format data:[mediatype];base64,[data]. This allows small files like images or fonts to be included inline without separate HTTP requests.