Base64 Encoder
Encode Unicode text or files to Base64 and decode results locally.
Data is processed only in your browserHow to use
Base64 Encoder supports encoding and decoding of both text and files. Full Unicode support includes Chinese characters, Emoji, and more. Encoding follows the RFC 4648 standard.
How to use: Paste text into the input field, or click "File Import" to upload a file. Click "Encode" to convert to Base64, or "Decode" to restore from Base64.
How Base64 Encoding Works
Base64 splits every 3 bytes (24 bits) of data into 4 groups of 6 bits each, mapping each group to a printable character (A-Z, a-z, 0-9, +, /). If the data length isn't a multiple of 3, = is used for padding.
| Input | Binary | Base64 Groups | Result |
|---|---|---|---|
A (65) | 01000001 | 010000 010000 | QQ== |
AB | 01000001 01000010 | 010000 010100 001000 | QUI= |
ABC | 01000001 01000010 01000011 | 010000 010100 001001 000011 | QUJD |
Common Use Cases
HTTP Basic Auth: Encode username:password as Base64 for the Authorization header.
Inline images: Convert small images to data:image/png;base64,... format for embedding in HTML/CSS.
Binary data in JSON: Use Base64 to transmit files, certificates, and other binary content in JSON.
Troubleshooting
Encoded data is larger? Base64 increases data size by ~33% (3 bytes become 4 characters) — this is inherent to the encoding scheme.
Decoding fails? Ensure the input is valid Base64 (only A-Z, a-z, 0-9, +, /, =). If the string comes from a URL, you may need to replace URL-safe -_ back to +/.
In code
Base64 encodes bytes, not characters, so encode UTF-8 first. btoa on its own throws on non-Latin1 input such as Chinese or emoji. The spread form below is fine for short strings; chunk large files.
JavaScript (browser)
const encode = s => btoa(String.fromCharCode(...new TextEncoder().encode(s)));
const decode = b => new TextDecoder().decode(
Uint8Array.from(atob(b), c => c.charCodeAt(0))
);
encode('你好'); // "5L2g5aW9"Python
import base64
base64.b64encode('你好'.encode()).decode() # '5L2g5aW9'
base64.b64decode('5L2g5aW9').decode() # '你好'Frequently asked questions
Does it support Chinese and Unicode?
Fully supported. The tool uses UTF-8 encoding internally, so Chinese, Japanese, Korean, Emoji, and all Unicode characters encode and decode correctly.
How much larger is Base64 encoded data?
Base64 converts every 3 bytes into 4 characters, making the encoded size about 4/3 of the original (roughly 33% larger). This is inherent to Base64 encoding.
Can it encode and decode files?
Yes. In Encode mode, upload a file (up to 20 MB) and the tool turns its raw bytes into a Base64 string, which you can also download. Decode mode shows a text preview of the decoded bytes and offers the raw bytes as a download — Base64 carries no file name, so it saves as decoded.bin.