Base64 encoder and decoder
Encode text or a file to Base64 and decode it back, in the standard or the URL-safe alphabet, with accents and every language kept intact. It runs on your device: nothing is sent.
How it works
Choose Encode to turn text or a file into Base64, or Decode to turn Base64 back into text or a file. The result appears on the right as you type.
- Text is read as UTF-8, so accented letters, Haitian Creole, Greek, Chinese and emoji come back exactly as they were.
- A file, an image or anything else, can be opened or dropped onto the input. Its Base64 can be shown and copied as a data URL, ready to put in a web page or a style sheet.
- Standard or URL-safe: the URL-safe alphabet writes
-and_where the standard one writes+and/, and its padding (=) can be left out. - Lines of 76 breaks the Base64 into lines of 76 characters, as email (MIME) does. Line breaks and spaces are passed over when decoding.
- Swap puts the result into the input and turns the direction round.
What Base64 is
Base64 writes any bytes with 64 characters that pass everywhere text does: A to Z, a to z, 0 to 9, and two more. Every 3 bytes become 4 characters, so Base64 is about a third longer than what it holds. When the bytes do not fill the last group, = signs pad it: f is Zg==, fo is Zm8=, foo is Zm9v.
When the Base64 is broken
The first problem is named in words, with its line and column, and marked in the input: a character that is not in the alphabet (!), a character of the other alphabet (- in standard Base64), letters after the padding, too many =, or a single character left over at the end, often a sign that something was cut off.
When the decoded bytes are not text, they are not shown as garbled characters. The tool says so, recognises a PNG, JPEG, GIF or WebP image, a PDF or a ZIP file by its first bytes, shows a decoded image, and offers to download the bytes as a file.
Questions and answers
Is what I paste or open sent anywhere?
No. It is encoded and decoded in your browser, on your device. Nothing you type, paste or open is uploaded, and nothing is kept once you close the page.
Is Base64 a kind of encryption?
No. Base64 only writes bytes with 64 ordinary characters, so that they can travel where only text is allowed. Anyone can decode it; it hides nothing.
Why does é become w6k= and not one character?
Text is first turned into bytes with UTF-8, the encoding of the web. A letter of the English alphabet is one byte, é is two (c3 a9), most Greek, Arabic or Hebrew letters two, Chinese and Japanese characters three, an emoji four. Base64 writes those bytes, so decoding gives back exactly the same letters.
What is the difference between standard and URL-safe?
The standard alphabet uses + and /, which have a meaning in a web address. The URL-safe alphabet (RFC 4648 §5, also called base64url) uses - and _ instead, and often leaves out the = at the end. JSON Web Tokens use it. +/8= and -_8 are the same two bytes.
What is a data URL?
An address that holds a whole file, written as data:, its type, ;base64, and its Base64, such as data:image/png;base64,iVBOR… A web page can use it as an image's address without a separate file. Open or drop a file, then choose Data URL.
Why does decoding say that the bytes are not text?
Base64 can hold any bytes, an image or a compressed file as well as text. When the decoded bytes are not valid UTF-8 text, the tool says so, names the kind of file when it recognises it, and offers to save them, instead of showing meaningless characters.
Runs on your device. Nothing you type or open is sent anywhere.