What is Base64?
Base64 is a way to represent data using only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, plus and slash, with an equals sign used for padding. It lets binary data, or text with unusual characters, travel through systems that only handle plain text, such as email, JSON and URLs.
Base64 is an encoding, not encryption. Anyone can decode it, so it gives no secrecy. It is also not compression: the output is about one third larger than the input, because every three bytes become four characters.
How to encode and decode Base64
- Choose Encode text to Base64 or Decode Base64 to text.
- Paste your text or Base64 string into the input box.
- Press Convert. The result appears below and updates as you type.
- Copy the result, or press Use result as input to chain another conversion.
Where Base64 is used
- Data URIs, which embed small images or fonts directly inside HTML and CSS.
- Email attachments, through the MIME standard.
- HTTP Basic authentication, where username:password is Base64 encoded in a header. This is not secure without HTTPS.
- JSON Web Tokens, which use URL-safe Base64 for their parts.
- APIs that send small files or binary values inside JSON.
URL-safe Base64 and padding
Standard Base64 uses plus and slash, which have special meanings in URLs. The URL-safe variant, called base64url, replaces them with minus and underscore, and many systems also drop the equals padding. Tick URL-safe to produce that form, and untick Keep padding to remove the equals signs. When decoding, the tool accepts both forms and adds padding as needed.
Unicode and errors
Browsers' built-in Base64 functions only handle simple Latin text, which makes plain use of them fail on emoji or accented letters. This tool converts text to UTF-8 bytes before encoding and decodes through UTF-8, so international text works. If you try to decode a string that is not valid Base64, or that decodes to bytes that are not text, you will see a message instead of garbled output.
How Base64 works, step by step
Base64 takes the data three bytes at a time. Three bytes are 24 bits, and those 24 bits are split into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and each number is replaced by a character from the Base64 alphabet. The three letters Man, for example, become the four characters TWFu. If the input does not divide evenly into groups of three bytes, the output is padded with one or two equals signs at the end.
This is also why Base64 text is always a multiple of four characters long when padding is included, and why the output is about 33 percent larger than the original. The size cost is the price of using only safe, printable characters.
Base64 for images and data URIs
A data URI lets you place a small image directly in HTML or CSS, using the form data:image/png;base64 followed by a comma and the Base64 text. It saves one network request, which can help for tiny icons, but it makes the page larger and the image cannot be cached on its own, so it is not suitable for large pictures. This tool works with text. To turn an image file into Base64, use a tool that reads the file as binary data.
Common Base64 mistakes
- Treating Base64 as encryption. It protects nothing, and anyone can reverse it in one click.
- Mixing up standard and URL-safe Base64. Tokens such as JWTs use the URL-safe form, so a plus or slash in the wrong place will not decode.
- Adding line breaks or spaces inside the string. This tool ignores whitespace when decoding, but some systems do not.
- Dropping the equals padding and then using a strict decoder that requires it.
Base64 examples
| Text | Base64 |
|---|---|
| Hello | SGVsbG8= |
| Hello, World! | SGVsbG8sIFdvcmxkIQ== |
| Any Converts | QW55IENvbnZlcnRz |
| user:pass | dXNlcjpwYXNz |
Frequently Asked Questions
What is Base64 used for?
To carry binary data or special characters through systems that only handle plain text, such as email and JSON.
Is Base64 encryption?
No. It is a reversible encoding that anyone can decode. Do not use it to protect secrets.
Why does Base64 make data bigger?
Four characters represent every three bytes, which increases the size by about 33 percent.
What is URL-safe Base64?
A variant that uses minus and underscore instead of plus and slash, so the result is safe to place in a URL.
Why does decoding fail?
The text may contain characters that are not Base64, be cut off, or decode to non-text data.
Does it support emoji and accented letters?
Yes. The tool uses UTF-8 for encoding and decoding.
Is my text uploaded?
No. Conversion runs in your browser.