What Base64 does
Base64 represents arbitrary bytes using only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, plus and slash. It exists because many channels, such as email bodies, JSON strings, HTML attributes and URLs, were designed for text and may damage raw binary data. By turning every group of three bytes into four printable characters, Base64 lets that data pass intact. It is an encoding, not encryption. Anyone can reverse it, and the page makes that easy. The standard is RFC 4648, which also defines the related Base32 and Base16 encodings and the URL-safe variant covered on another page.
How the encoding works
The page first converts your text to UTF-8 bytes. It splits the bytes into groups of three, which is 24 bits, and cuts each group into four 6-bit values. Each value from 0 to 63 maps to a character in the alphabet. If the final group has one or two bytes, the output is padded with one or two equals signs so the length is a multiple of four. For the default text foobar, six bytes make two full groups, so there is no padding, and the result is Zm9vYmFy. The text foo gives Zm9v, and fooba gives Zm9vYmE=. These match the test vectors listed in RFC 4648.
Padding and length
Output length is 4 × ceil(n / 3) for n input bytes. One leftover byte gives two characters plus ==, as in a, which encodes as YQ==. Two leftover bytes give three characters plus a single =, as in ab, which encodes as YWI=. The text Man encodes as TWFu with no padding, the classic example from older documentation. Because every three bytes become four characters, Base64 makes data about one third larger, and email systems that add line breaks every 76 characters make it a little larger still. This page returns a single unbroken line without added line breaks.
Text beyond English
Because the page encodes UTF-8 bytes, accented letters and other scripts work, but each non-ASCII character becomes several bytes. The letter é is stored as the two bytes C3 A9, and the encoding of é is w6k=. A string of English text is shorter in Base64 than the same number of characters in a script that needs three bytes per character. If another tool gives a different result for the same text, the cause is usually a different character encoding before the Base64 step, such as UTF-16 or Latin-1. This page always uses UTF-8, which is the normal choice for the web. Byte counts matter for length limits too. The word café has four characters but five UTF-8 bytes, and its Base64 form is Y2Fmw6k=, which is eight characters long because five bytes need two groups of three with padding.
Decoding strictly
Decoding accepts canonical standard Base64. The page checks that every character belongs to the alphabet, that padding is correct, and that the unused bits in the last character are zero. For example, Zg== is the canonical form of f, but Zh== also carries the data f in some lenient decoders and is rejected here because the leftover bits are not zero. Line breaks, spaces and URL-safe characters such as minus and underscore are not accepted. This strictness helps catch truncated or corrupted data. After decoding, the bytes must form valid UTF-8, because the output of this page is text.
Binary data will not decode as text
Base64 is often used for images, keys, certificates and compressed data. If you paste the Base64 of a PNG file or an encrypted blob into the decode box, the result is not valid UTF-8, and the page rejects it with an error. The page has no option for byte output or file download, so it is meant for text. For quick inspection of a token or a small configuration string it works well. If you need the raw bytes of an image, use a tool that supports binary output and keeps the data out of a text field.
Where you will meet it
Common uses include HTTP Basic authentication, where a username and password are joined with a colon and Base64 encoded, data URLs in web pages, email attachments under MIME, and PEM files for certificates. The header and payload of a JSON Web Token use the URL-safe variant instead. Encoding the phrase Hello, World! gives SGVsbG8sIFdvcmxkIQ==. Because Base64 hides nothing, never treat an encoded credential as protected. A Basic authentication header sent over plain HTTP exposes the password to anyone who can read the traffic, and only TLS protects it. Data URLs follow a similar pattern, placing the Base64 text after a media type and a base64 marker, which is why small icons can be embedded directly in a style sheet. The size cost of roughly one third is the price of that convenience, and large files are usually better served as separate downloads. Email attachments also use Base64 under MIME, which is why a 3 MB attachment makes a message of about 4 MB.
Privacy and handling
The page processes text in your browser, and the text limit is 1 MiB of UTF-8. Even so, avoid pasting live secrets, private keys or customer data into any online page when a local tool is available. When you copy a result, keep the equals signs at the end, since many decoders require them. Whitespace added by a chat program or email client can break a Base64 string, so check for stray spaces or line breaks if decoding fails. Keep the mode you used with the result, because an encoded string and its decoded form look nothing alike. A useful sanity check is length: an encoded string whose length is not a multiple of four, with no padding at the end, is probably truncated or was produced in the URL-safe unpadded form. Testing a short known string such as foo, which must give Zm9v, confirms that you are using the standard alphabet.
Base64 input rules and malformed padding
Input must be valid Unicode text without unpaired surrogates. Decoding rejects malformed padding, characters outside the standard alphabet, nonzero unused bits and bytes that are not valid UTF-8. The output is text only. There is no byte output option, no line wrapping and no MIME or URL-safe mode here. For the URL-safe alphabet with minus and underscore, use the Base64Url encoder on this site. The page makes no claim about the safety of the content you decode, and decoded text should be treated like any other untrusted input.