Base64 Encode / Decode
Chinese text and emoji won't be garbled — everything is handled as UTF-8 internally. Content is processed only in your browser.
Many online tools use btoa() It works on strings directly, so Chinese characters throw an error or turn into mojibake. Here it first uses TextEncoder Converts to UTF-8 bytes before encoding and reverses it when decoding.
When to use it
- You need to place text containing Chinese or emoji into a field that accepts ASCII only, such as an HTTP header or a config value.
- You have a Base64 string and need to know whether it decodes to readable UTF-8 text, or why it turns into garbled characters.
When not to
- You want to encode an image, PDF or zip: this tool handles text only and cannot preserve binary bytes, so use the base64 command or a file-aware tool.
- You are trying to encrypt or hide a password or token: Base64 is encoding, not protection — anyone who receives it can decode it.
Encoding and decoding run entirely in your browser; input is never uploaded and is not written to the URL or a log. Limits: text only — no file or binary conversion; decoding assumes UTF-8, so Base64 of non-UTF-8 bytes shows � replacement characters; whitespace is ignored, but any character outside the Base64 alphabet is an error; output is about 4/3 the UTF-8 byte length of the input.
Frequently asked
Why do other tools garble Chinese text?
Many pass the JavaScript string straight to btoa(). btoa() only accepts a binary string whose characters are 0–255, so Chinese throws InvalidCharacterError; workarounds that skip UTF-8 then produce mojibake when the other side decodes it. This tool runs TextEncoder first to get UTF-8 bytes, encodes those bytes with btoa(), and reverses the process with TextDecoder on decode, so Chinese and emoji round-trip unchanged.
How much larger does Base64 make text?
About 33%. Every 3 bytes become 4 ASCII characters, so the length is 4/3 of the original, plus one or two = padding characters when the byte length is not a multiple of three. In UTF-8 a Chinese character is 3 bytes and becomes about 4 Base64 characters; an emoji is usually 4 bytes and becomes about 8 characters including padding.
Can it encode an image or a PDF?
No. This tool takes text only: on encode, TextEncoder treats the input as UTF-8 text, so the bytes of a binary file are not preserved; on decode, bytes that are not valid UTF-8 become � (U+FFFD) and the file is corrupted. For files, use the base64 command on macOS/Linux, certutil on Windows, or a tool that reads bytes.