Base64 Encoder and Decoder
Switch between Encode and Decode, paste your input, and the result appears below with its length. Text goes through UTF-8 first, so emoji and other characters outside Latin-1 encode instead of throwing the error a bare btoa() call gives, and accented letters come out as their UTF-8 bytes. In Encode mode you can also pick a file and get its bare Base64 string; prefix it with something like data:image/png;base64, to inline a small icon.
How to encode or decode
- Choose Encode or Decode. The label above the box and the action button change to match.
- Paste into the text box. For Encode you can instead use the file picker under Or Upload a File (Encode Only), which is disabled in Decode mode. Choosing a file produces its Base64 immediately.
- Click the action button. The converted text appears under Result with a character count.
- Click Copy to copy the result. If the Base64 is invalid you get an error message instead.
What Base64 is, and what this tool assumes
Base64 maps every three bytes to four characters from a 64-character alphabet, so output is about a third larger than the input. It exists to carry binary data through channels that only handle text, such as JSON fields, email bodies and data URIs. It is an encoding, not encryption: anyone can reverse it, so never use it to hide a secret.
Because the browser's btoa() only accepts Latin-1, this tool encodes text through UTF-8 before converting. Decoding assumes the bytes are UTF-8 text. If you decode Base64 that holds an image or other binary data, the tool usually reports an invalid string, since raw bytes are rarely valid UTF-8 text. For binary payloads, use a tool that can save the decoded bytes as a file.
The alphabet used is standard Base64 with +, / and = padding. URL-safe Base64, which uses - and _, is not converted automatically, so swap them back to + and / if a token comes from a JWT or a URL, otherwise decoding fails. Missing = padding is tolerated by the browser's decoder. Files are read and encoded in your browser, and the code makes no network request, so a file you pick is not uploaded anywhere. Large files produce very long strings, so expect the output box to get heavy.