← Back

Base64 Tool

Encode and decode text as Base64

Output
—

About Base64 Tool

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.

How to use it

  1. Put your content in the 'Input' box: plain text if you want to encode it, or a Base64 string if you want to decode it.
  2. Click 'Encode →' and the 'Output' area shows the Base64 for that text.
  3. Click 'Decode →' and the output shows the decoded text. If the input is not valid Base64, a red message says 'Not a valid Base64 string'.
  4. To convert a file, click 'Upload File to Encode' and choose one. The output shows the file's Base64 string directly, without a data: prefix. This does not read or change what is in the Input box.
  5. Once there is output, use the copy button next to the 'Output' label to put the result on your clipboard.

Worked examples

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.

Supported scope and known limits

  • Text is encoded as UTF-8, and decoding also interprets the bytes as UTF-8 text. It is therefore only suitable for decoding Base64 whose original content was text.
  • If the Base64 contains binary data such as an image or archive (not valid UTF-8 text), 'Decode →' shows 'Valid Base64, but the decoded data is not UTF-8 text (it may be binary)' rather than calling the string invalid. The tool cannot save decoded bytes as a file.
  • Decoding accepts both the standard alphabet (A-Z, a-z, 0-9, +, / and =) and the URL-safe variant, which uses - and _ in place of + and /. Missing = padding is added automatically.
  • File conversion goes one way only, file to Base64, and the output is bare Base64 without a prefix such as data:image/png;base64, which you can add yourself. There is no size cap, but the whole file is read into browser memory and printed on the page, so files of tens of megabytes can make the page slow or unresponsive.
  • Encoded data is about one third larger than the original, which is how Base64 works.
  • On failure the page shows a short error without saying where the problem is. Text containing a broken surrogate (for example a truncated emoji) fails to encode and shows 'Encoding failed'.
  • The output is a single line and is not wrapped at 76 characters. If you need MIME-style wrapping, do that yourself.

FAQ: Is Base64 encryption? Can it protect my data?

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.

FAQ: Why do I get garbled output or an error when decoding?

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.

FAQ: How do I turn a file into an image I can embed in a page?

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.

FAQ: Is my file uploaded to a server?

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.

Privacy and processing

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.