How to use it
- 1.Choose Encode to turn text or a file into Base64, or Decode to turn Base64 back into text or a file.
- 2.Type or paste into the box. The result updates as you type. To encode a file, click “Choose a file” or drop it onto the box.
- 3.Turn on “URL-safe alphabet” for Base64 that goes into URLs, file names or tokens, or “Output as a data URL” to embed an image straight into HTML or CSS.
- 4.To decode, paste plain Base64 or a whole
data:URL. If the result is a file rather than text, you’ll see its type and can download it. - 5.Click Swap to feed the result back in and check that the round trip gives you what you started with.
What is Base64?
Base64 writes any data (text, images, PDFs) using only 64 characters that survive every system: A–Z, a–z, 0–9, + and /. It exists because email, JSON, XML, URLs and many older protocols only carry plain text safely, while files are made of raw bytes.
The encoding takes the input three bytes at a time and writes each group of 24 bits as four characters of 6 bits each. That’s why Base64 is about 33% larger than the original, and why it often ends with = or ==: when the input isn’t a multiple of three bytes, padding fills the last group.
Base64 is an encoding, not encryption. There’s no key and anyone can decode it instantly, so it never protects passwords or personal data.
Standard and URL-safe Base64
Standard Base64 (RFC 4648) uses + and /, which have special meanings in URLs and file paths. URL-safe Base64, also called base64url, replaces them with - and _ and usually leaves out the = padding. JSON Web Tokens and many web APIs use it.
This decoder accepts both alphabets, with or without padding, and ignores spaces and line breaks. You can paste Base64 from an email, a PEM certificate or a log file without cleaning it up first.
Text, UTF-8 and data URLs
Base64 encodes bytes, not letters, so text has to become bytes first. This tool uses UTF-8, the character encoding of almost every website and API, which means accented letters, other alphabets and emoji all encode correctly and decode back exactly.
A data URL packs a whole file into a link: data:image/png;base64, followed by the Base64 data. Browsers display it like any other image, which is handy for small icons in HTML, CSS or email templates. For larger files, a normal file is better: the data URL is a third bigger and can’t be cached on its own.
Questions and answers
Is Base64 a form of encryption?
No. Base64 only changes how data is written down; there’s no key, and anyone can decode it in a second. To protect sensitive data, use real encryption, such as AES, or keep secrets in a password manager.
Why do Base64 strings end with = or ==?
Base64 turns every 3 bytes into 4 characters. When the length of the data isn’t a multiple of three, the last group is filled up with one or two = signs. URL-safe Base64 often omits them, because a decoder can work out the length without them.
How much bigger does Base64 make a file?
About a third: every 3 bytes become 4 characters, so a 300 kB image turns into roughly 400 kB of Base64. MIME line breaks add one more character for every 76.
How do I convert an image to Base64?
Choose Encode, click “Choose a file” and pick the image. Turn on “Output as a data URL” to get a string you can paste into an <img src="…"> attribute or a CSS url(). The image is read in your browser and never uploaded.
Why does my decoded text look garbled?
Either the data isn’t text at all (it may be an image, a PDF or a zip file) or the text was saved in a character set other than UTF-8, such as Windows-1252. When the bytes aren’t readable text, this tool shows them in hex, detects the file type where it can and lets you download the file.