
Base64 Encoder / Decoder
Encode or decode Base64 strings with full UTF-8 support. 100% client-side.
Last reviewed: April 2026New to this tool? Click here for instructions
Quick Answer
Base64 is an encoding that represents binary data using 64 ASCII characters, so it can travel safely through text-only channels like URLs, email, and JSON. This tool encodes text or files to Base64 and decodes Base64 back to the original. Note that Base64 is not encryption โ it is easily reversible and provides no security. Everything runs in your browser.
How to Use the Base64 Encoder/Decoder
- Paste your text or Base64 string into the input area on the left (or top on mobile).
- Choose a mode - Encode, Decode, URL-Safe Encode, or URL-Safe Decode.
- View the result - the converted output appears instantly on the right.
- Copy or download - use the buttons above the output to copy to clipboard or download as a text file.
What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 printable ASCII characters. The standard Base64 alphabet includes uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and slash (/), with equals (=) used as padding. This encoding is essential when you need to transmit binary data through text-based protocols or embed binary content in text documents.
Common Use Cases
- Data URIs - embed images, fonts, and other assets directly in HTML or CSS using
data:image/png;base64,... - Email attachments - MIME encoding uses Base64 to attach binary files to email messages
- API payloads - transmit binary data (images, PDFs, certificates) inside JSON API requests and responses
- Authentication - HTTP Basic Authentication encodes username:password in Base64
- Cryptographic data - store and transmit encryption keys, certificates, and signatures as text
- Configuration files - embed secrets or binary blobs in YAML, TOML, or environment variables
Standard vs. URL-Safe Base64
Standard Base64 uses the characters + and / which have special meaning in URLs. URL-safe Base64 (also called Base64url, defined in RFC 4648) replaces + with - and / with _, and omits the trailing = padding. This variant is used in JSON Web Tokens (JWTs), URL query parameters, and filenames where special characters would cause problems - pair this with our JWT Decoder to inspect token payloads.
UTF-8 Support
JavaScript's built-in btoa() function only handles Latin-1 characters (code points 0-255). This tool uses the TextEncoder and TextDecoder APIs to properly encode and decode multi-byte UTF-8 characters, including emojis, Chinese/Japanese/Korean characters, Arabic, Cyrillic, and other Unicode scripts. The process converts the string to a UTF-8 byte array first, then Base64-encodes each byte.
How Base64 Works Internally
Base64 encoding processes input data in groups of 3 bytes (24 bits). Each group is split into four 6-bit values, and each 6-bit value is mapped to one of 64 characters in the Base64 alphabet. If the input length is not a multiple of 3, padding characters (=) are added. This means Base64-encoded data is always approximately 33% larger than the original binary data.
Size Overhead
Every 3 bytes of input produce 4 bytes of Base64 output. This 33% size increase is an important consideration when Base64-encoding large files. For example, a 1 MB image becomes approximately 1.33 MB when Base64-encoded. For large assets, it is often more efficient to serve them as separate files rather than embedding them inline as Base64.
Base64 in Data URIs
Data URIs use the format data:[mediatype];base64,[data] to embed files directly in HTML or CSS. For example, a small PNG icon can be embedded as data:image/png;base64,iVBOR..., eliminating an extra HTTP request. This technique is most effective for files under 10 KB -- larger files are better served as separate assets since Base64 encoding adds 33% overhead. For related encoding and security tools, check out our Hash Generator and .env Redactor.
How to Use the Base64 Encoder/Decoder
To use the Base64 Encoder/Decoder, simply paste your text or Base64 string into the input area on the left (or top on mobile). Choose a mode - Encode, Decode, URL-Safe Encode, or URL-Safe Decode. View the result - the converted output appears instantly on the right. Copy or download - use the buttons above the output to copy to clipboard or download as a text file.
What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 printable ASCII characters. The standard Base64 alphabet includes uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and slash (/), with equals (=) used as padding. This encoding is essential when you need to transmit binary data through text-based protocols or embed binary content in text documents.
How It Works
Base64 encoding processes input data in groups of 3 bytes (24 bits). Each group is split into four 6-bit values, and each 6-bit value is mapped to one of 64 characters in the Base64 alphabet. If the input length is not a multiple of 3, padding characters ( = ) are added. This means Base64-encoded data is always approximately 33% larger than the original binary data.
Tips and Limitations
JavaScript's built-in btoa() function only handles Latin-1 characters (code points 0-255). This tool uses the TextEncoder and TextDecoder APIs to properly encode and decode multi-byte UTF-8 characters, including emojis, Chinese/Japanese/Korean characters, Arabic, Cyrillic, and other Unicode scripts.
Frequently Asked Questions
Quick reference
| Parameter | Encoder Output | Decoder Output | Notes |
|---|---|---|---|
| Input Text | SGVsbG8= | Hello | Standard encoding of "Hello" |
| Binary Data | QmFzZTY0 | Base64 | Encodes ASCII "Base64" to binary |
| Special Characters | U3BhY2U= | Space | Encodes space character (ASCII 32) |
| Long String | RXhhbXBsZSBUcmlzb24= | Example String | Encodes 14-character input |
| Padding | MTIzNDU2Nzg5 | 123456789 | Padding '=' ensures 4-byte alignment |
| Whitespace | U3BhY2UgU25h | Space String | Decoder ignores trailing spaces |
Example walk-through
Worked example: step-by-step
Step 1. Input text to encode:
"Hello, World!"
Step 2. Convert text to UTF-8 bytes:
[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
Step 3. Split bytes into 6-bit groups and map to Base64 alphabet:
"SGVsbG8sIFdvcmxkIQ=="
Step 4. Decode Base64 string back to bytes:
[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
Step 5. Convert bytes back to text:
"Hello, World!"
Step 6. Handle URL-safe encoding (replace '+' with '-' and '/' with '_'):
"SGVsbG8sIFdvcmxkIQ==" โ "SGVsbG8sIFdvcmxkIQ" (this string contains no '+' or '/', so only the trailing '=' padding is dropped)