How to encode text to Base64
Type or paste text into the left box and the Base64 appears on the right. Accented letters, other alphabets and emoji are encoded as UTF-8 first, which is what nearly every program expects, so the result decodes correctly anywhere.
Tick URL-safe Base64 if the result will go into a web address or file name. This version uses - and _ instead of + and /, and leaves off the = padding.
How Base64 encoding works
Base64 takes the data three bytes, or 24 bits, at a time and splits them into four groups of six bits. Each group is a number from 0 to 63, which is written as one of 64 characters: A to Z, a to z, 0 to 9, + and /. If the data does not divide exactly into threes, = signs are added at the end.
So the word Man, whose bytes are 77, 97 and 110, becomes TWFu. The result is always about a third longer than the original, which is the price paid for being safe to send as plain text.
Remember that Base64 hides nothing. It is used to package data, not to protect it.
A common use is a data URL, which puts a small image straight into a web page or email as Base64, so it does not need a separate file.
Questions and answers
Why is the Base64 longer than my text?
Base64 uses four characters for every three bytes, so it is about 33 per cent longer.
What are the = signs at the end?
Padding. They make the length a multiple of four when the data does not divide exactly into groups of three bytes.
Can I encode a file?
This tool encodes text only. For files, most operating systems include a base64 command.
Does it work with emoji?
Yes. Text is encoded as UTF-8 first, so emoji and accented letters are encoded correctly.