Base64 Encoder
Encode any text to Base64 (Unicode-safe).
Was this tool helpful?
Thanks for the feedback!
The Base64 Encoder converts any text you type or paste into a Base64 string. It first turns the text into UTF-8 bytes and then encodes those bytes, which is what "Unicode-safe" means here: Hindi, Bengali, emoji and the ₹ sign all encode correctly, while the browser's bare btoa() function throws an error on them.
The 3-bytes-to-4-characters rule
Base64 (RFC 4648) reads the input three bytes at a time, splits those 24 bits into four 6-bit numbers, and writes each number as one character from the alphabet A–Z, a–z, 0–9, +, /. Take the word "Man":
- M = 77 =
01001101, a = 97 =01100001, n = 110 =01101110 - Regrouped into sixes:
010011 010110 000101 101110= 19, 22, 5, 46 - Characters 19, 22, 5 and 46 of the alphabet are T, W, F and u, so "Man" becomes
TWFu
When the last group is short, = fills the gap: "Ma" encodes to TWE= and "M" to TQ==. The output length is always 4 × ⌈bytes ÷ 3⌉, which makes Base64 about 33% larger than the original. "Hello, World!" is 13 bytes and becomes the 20-character SGVsbG8sIFdvcmxkIQ==.
Details that change the output
- Every character counts. The input is not trimmed, so a trailing line break is encoded too: "Hello" gives
SGVsbG8=but "Hello" plus Enter givesSGVsbG8K. This is the usual reason two encoders disagree. - Non-English text grows fast. Most Devanagari letters take three bytes in UTF-8, so the six-character word नमस्ते (18 bytes) becomes a 24-character string,
4KSo4KSu4KS44KWN4KSk4KWH. - Standard alphabet, one line. The result uses
+,/and padding, with no line wrapping. For a URL, either percent-encode it with the URL Encoder or convert it to Base64URL by swapping+for-,/for_and dropping the=.
Where encoded text is needed
HTTP Basic authentication. Encode username:password and send it as Authorization: Basic dXNlcjpwYXNz (that string is "user:pass"). Only do this over HTTPS, because the header can be decoded by anyone who sees it.
Kubernetes Secrets and config files. Values under a Secret's data: key must be Base64. Because the tool encodes exactly what is in the box, make sure there is no trailing newline, the same mistake people make with echo instead of echo -n on the command line.
Embedding text in JSON, XML or data URIs. Base64 lets you carry text with quotes, line breaks or unusual symbols through systems that would otherwise mangle them, for example data:text/plain;base64,SGVsbG8=.
What this encoder is not for
It encodes text only; to turn a picture into a data URI, use the Image to Base64 Converter. It also provides no secrecy, since decoding needs no key. Encoding happens in your browser, so the text you enter stays on your device.