Base64 encode and decode
Encode text or a file to Base64, or decode it back, with URL-safe alphabet, Data URI and MIME line wrapping all handled.
Drop your files here
.txt, .b64, .base64 · up to 150 MB
How to encode and decode Base64
- 1
Choose encode or decode
The same screen works both ways, and the direction is the first thing you set so nothing is encoded twice by accident.
- 2
Paste text or drop a file
Any file type can be encoded; decoding accepts a pasted string, a Data URI, or a text file containing one.
- 3
Copy the result or download it
Decoded output is recognised as text or binary automatically and named with the right extension.
What Base64 is for, and what it is not
Base64 exists because some channels only carry printable text: email bodies, JSON string fields, HTML attributes, HTTP headers. It maps every three bytes onto four characters from a 64-character alphabet, which is why the output is always about a third larger than the input. It is an encoding, not encryption: anyone can decode it without a key, and the alphabet is public. If the content is a secret, Base64 does nothing to protect it, and a token pasted into a Base64 field is exactly as exposed after encoding as before.
Data URIs and the URL-safe alphabet
A Data URI wraps the encoded bytes in a prefix that names their media type, so data:image/png;base64,… can be used directly as an image source or a CSS background. When encoding a file the media type comes from the file itself; when encoding pasted text you supply it. The URL-safe alphabet replaces + and / with - and _ and drops the trailing padding, because those three characters have their own meaning inside a URL or a filename. Decoding accepts either alphabet without being told which, and ignores line breaks entirely, so MIME-wrapped and PEM-wrapped strings paste in unchanged.
Precise errors instead of silent nonsense
A Base64 string that contains a character outside the alphabet, or whose length leaves a remainder of one when divided by four, cannot decode to anything meaningful. Rather than returning truncated bytes, the position of the offending character is reported so it can be found in a long string. A Data URI that is percent-encoded rather than Base64 is a real and confusing case, since both start with data:. Such a string is identified and pointed at the URL decoder instead of being read as Base64 and producing rubbish.
Encoded in your browser, not on a server
The conversion runs entirely in this tab using the browser's own primitives, in chunks so that a large file does not exhaust memory. Nothing is uploaded, which matters because Base64 payloads routinely contain certificates, keys and private documents.
Frequently asked questions
Is Base64 a form of encryption?
No. It is a reversible encoding with a public alphabet and no key. Anyone who has the string can recover the original bytes, so it protects nothing; it only makes binary data safe to carry through text-only channels.
What is a Data URI?
A string that carries a file's media type and its Base64 content together, like data:image/png;base64,iVBOR… It can be used directly as an image source or a CSS background, avoiding a separate network request for a small asset.
Why would I need the URL-safe alphabet?
Because + and / are meaningful inside URLs and filenames, and = has its own role in query strings. The URL-safe variant uses - and _ instead and omits the padding, which is what JWTs and many APIs expect.
Why is the result a third longer than the input?
Three bytes become four characters by design, so the output is 4/3 the size before any line breaks. That overhead is the price of using only printable characters.
How do I decode to a file rather than text?
Automatic mode already does it: if the decoded bytes are not valid UTF-8 text, you get a file. You can also force the file path and set the filename, and the extension is corrected from the media type when a Data URI supplied one.
Why do I get an invalid character error?
Because the string contains something outside the Base64 alphabet, often a stray quote or an HTML entity picked up while copying, or because it was truncated. The reported position points at the exact character to look at.
Is my file uploaded?
No. Encoding and decoding both run locally in your browser using built-in functions, with no library and no server, and nothing is retained after the tab closes.