Encode and decode text as Base64
Base64 is a way of writing any binary data using 64 printable characters. It is used wherever data has to travel through plain-text channels, such as email attachments, images embedded in web pages as data URIs, and tokens or settings passed through APIs. This tool offers three things: encode text to Base64, decode a Base64 string back to text, and convert a file you pick into a Base64 string. Text is handled as UTF-8, so Chinese characters and emoji survive the round trip. One thing must be stated clearly: Base64 is an encoding, not encryption. Anyone can reverse it, so it must never be used to protect passwords or private data.
These results come from running the same method as the tool. Encoding 'Hello' gives SGVsbG8=. Encoding 'Hello, 世界' gives SGVsbG8sIOS4lueVjA==, where the two Chinese characters take up the tail of the string because they are six bytes in UTF-8. Decoding SGVsbG8sIOS4lueVjA== returns 'Hello, 世界'. The equals signs are padding that brings the length to a multiple of 4; decoding SGVsbG8 without padding still returns Hello because the browser's decoder tolerates missing padding. Spaces and line breaks in the input are ignored when decoding, so Base64 copied from an email in several lines can usually be pasted in as it is.
No, on both counts. Base64 is just a different way of writing the same data. There is no key, and anyone holding the string can decode it with a tool like this one. Using it to hide a password or personal information gives no protection. If you need to protect data, use real encryption.
Typical causes are an incomplete string (missing characters at either end), original data that is a binary file rather than text, or text that was not UTF-8 to begin with, such as GBK text from an older system. Check that the string is complete first, then look at the character set used by the system that produced it.
Use 'Upload File to Encode' to get the Base64, then add data:image/png;base64, in front of it (use the real type of your file, such as image/jpeg). You can then use it as an inline image in HTML or CSS. That suits small icons; larger images make the page heavier and are usually better served as separate files.
No. 'Upload' in 'Upload File to Encode' just means choosing the file in the page. Reading and conversion are done by your browser locally, and the content is not sent to us or to any third party.
Text encoding, decoding and file conversion all happen in your browser. The code makes no request that sends your input or files to a server and writes nothing to local storage. Reloading the page clears input and output. The copy button uses your browser's clipboard feature, so the content only goes to your own clipboard. If you handle sensitive items such as tokens or keys, use a device you trust and avoid pasting the results anywhere public.