What Is Base64 Encoding
Base64 is a way to turn binary data into plain text. It maps any sequence of bytes onto a set of 64 printable ASCII characters, which means the output can travel safely through systems that only handle text. The format was born in the MIME email standard, where binary attachments had to survive mail servers that stripped non-text bytes.
The 64-character alphabet is fixed:
| Value | Characters | Count |
|-------|-----------|-------|
| 0-25 | A-Z | 26 |
| 26-51 | a-z | 26 |
| 52-61 | 0-9 | 10 |
| 62 | + | 1 |
| 63 | / | 1 |
A 65th character, =, shows up only at the end as padding.
How the Encoding Works
Base64 reads input bytes in groups of three (24 bits total) and splits them into four 6-bit chunks. Each chunk maps to one character in the alphabet, so three bytes become four characters.
Take the string Man:
Input bytes: M(77) a(97) n(110)
Binary: 01001101 01100001 01101110
6-bit groups: 010011 010110 000101 101110
Decimal: 19 22 5 46
Alphabet: T W F u
The result is TWFu.
When the input length is not a multiple of three, padding kicks in:
- One leftover byte produces two characters plus
== - Two leftover bytes produce three characters plus
=
That is why Base64 strings often end with one or two equals signs. It's normal, not a bug.
Handling Unicode, Chinese, and Emoji
Base64 operates on bytes, not characters. Chinese characters, emoji, and other non-ASCII symbols occupy multiple bytes under UTF-8. A Chinese character typically takes three bytes, and an emoji can take four.
The correct approach is to encode the string into a UTF-8 byte sequence first, then run Base64 over those bytes. Tools that skip this step and treat each character as a single byte end up mangling Chinese text or turning it into \uXXXX escape sequences.
On a UTF-8 terminal, the round trip works cleanly:
echo -n "你好" | base64
# 5ZG95ZG9
echo "5ZG95ZG9" | base64 -d
# 你好
DevToolkit Pro's Base64 tool follows the UTF-8 byte path, so Chinese, Japanese, and emoji all survive a full encode-decode round trip without corruption.
URL-Safe Base64
Standard Base64 includes + and /, which collide with URL syntax and file naming rules. The URL-safe variant (also called Base64url) swaps two characters and drops padding:
-replaces+_replaces/- The trailing
=padding is removed
| Standard | URL-Safe |
|----------|----------|
| a+b/c= | a-b_c |
You will find this variant inside JWT tokens, in Data URLs, and in short-link systems. Anywhere your encoded string lands inside a URL, switch to the URL-safe alphabet to avoid parsing headaches.
Using the Online Tool
The Base64 encoder and decoder in DevToolkit Pro keeps things simple:
- Open the tool page
- Paste your text into the input box
- Pick Encode or Decode
- Read the result from the output area, and copy it with one click
Everything runs locally in your browser. Nothing leaves your device, which makes the tool safe for strings that carry tokens or credentials.
FAQ
Is Base64 encryption?
No. Base64 is encoding, not encryption. Anyone can reverse it. It solves a transport problem, not a secrecy one. For confidentiality, reach for AES or another real cipher.
Does encoding change the size?
Yes, it grows by about 33 percent. Three bytes become four characters, so Base64 is a transport format, not a compression tool.
Why does my Chinese text turn into garbage after encoding?
The tool you used probably skipped the UTF-8 byte conversion step. Switch to a Unicode-aware encoder and the round trip will work. A quick test: encode "你好", decode it back, and check whether the original characters return intact.
Can I store images as Base64?
You can. Embedding image bytes as a Base64 Data URL inside HTML or CSS saves an HTTP request. Keep in mind the payload grows by a third, so this trick works best for small icons and sprites, not large photos.
Article by DevToolkit Pro. Visit our homepage for more developer tools.
← Back to Blog