Encode to Base64
Text, an image, or any file — turned into Base64, correctly. Accented characters and emoji survive, which the usual one-line implementations do not manage. Nothing is stored.
- Never stored
- No queue, no waiting
- No signup, no watermark
Text is encoded as UTF-8, so accents and emoji survive.
Base64 appears here.
How it works
Paste text or drop a file
Text is encoded as UTF-8. A file is encoded byte for byte, and never stored.
Choose the flavour
Standard Base64, URL-safe Base64URL for tokens and query strings, or a full data URI ready to paste into CSS or an <img> tag.
Copy it
Copy the result, or download it as a text file if it is large.
Why it grows by exactly a third
Base64 takes three bytes at a time and writes them as four characters, each carrying six bits of the twenty-four. Four divided by three is where the famous 33 per cent comes from — it is arithmetic, not inefficiency, and no encoder does better while staying in the printable range. When the data does not divide evenly into threes, the last group is padded and marked with one or two = signs, which is why the length of any base64 string is always a multiple of four.
There are two alphabets, and picking the wrong one is the most common problem people bring here. The standard alphabet ends with + and /, both of which have meaning in a URL — the plus becomes a space in a query string and the slash looks like a path separator. The URL-safe variant uses - and _ instead, and is what JSON Web Tokens, filenames and anything appearing in an address use. They are otherwise identical, and a value encoded with one and decoded as the other fails in ways that look like data corruption.
Line wrapping is the other context-dependent detail. Email attachments expect lines of 76 characters, PEM certificates and keys expect 64, and a data URI or a JSON field expects no breaks at all. It is off by default here because unwrapped is the common case now; turn it on when the destination is an email header or a -----BEGIN----- block, which will reject a single enormous line.
Base64 is not encryption and offers no protection whatsoever. It is an alphabet change — anyone can reverse it instantly, and any security scanner does so automatically. Its purpose is to move binary data through channels that only accept text: email bodies, JSON fields, XML documents, data URIs in a stylesheet. Using it to hide a password in configuration obscures nothing from anyone who looks.
When you want something else
At the command line, base64 -w 0 file.bin encodes without wrapping on Linux and plain base64 does the same on macOS, while openssl base64 -A works identically everywhere. For the URL-safe alphabet, basenc --base64url is the one that gets it right without a substitution step.
For large files, everything here is the wrong approach — the whole file is held in memory, and encoding it inflates it by a third before anything else happens. Command-line tools stream instead, and in code every language has an incremental encoder. It is also worth asking whether the base64 is needed at all: sending binary as multipart/form-data or as a raw body avoids both the memory and the 33 per cent.
Frequently asked questions
Is my text or file stored anywhere?
No. Nothing is stored, nothing is logged, and no server ever sees it — and it keeps working with the network disconnected. For these tools in particular that is not a nicety. What people paste into online encoders and decoders is routinely live: session tokens, API keys, Authorization headers, customer records. Pasting one of those into a page that sends it somewhere is a disclosure, whatever the site promises about deletion.
Why do accented characters and emoji work here?
Because the text is converted to UTF-8 bytes before being encoded, which is the correct order and what most quick implementations skip. The browser's own `btoa` cannot take text at all — it takes one byte per character, so `btoa("café")` simply throws an error. The widespread workaround, `btoa(unescape(encodeURIComponent(s)))`, works by accident and falls apart on emoji and other characters outside the basic range. This page encodes UTF-8 properly, once, so 日本語 and 🎉 come through and decode back identically.
What is Base64URL and when do I need it?
It is Base64 with two characters swapped: + becomes -, / becomes _, and the trailing = padding is dropped. It exists because +, / and = all mean something in a URL, so ordinary Base64 gets mangled when it travels in a query string or a path. JWTs, OAuth tokens and anything in a URL use Base64URL. If you are putting the result in a link, pick it.
Does Base64 encrypt or protect anything?
No, and this is worth being blunt about. Base64 is an encoding, not encryption — there is no key and no secret. Anyone who sees the string can decode it in one step, including on this site. It exists to carry binary data safely through channels that only accept text, such as email attachments and data URIs. If something needs to be kept secret, it needs encryption; Base64 gives no protection whatsoever.
Why is the Base64 bigger than my file?
About 33% bigger, always. Base64 represents every 3 bytes as 4 text characters, so the size grows by a third by design, plus a little padding. That is the price of turning binary into text, and it is why embedding a large image as a data URI in your CSS is usually a bad trade.
Can I encode an image as a data URI?
Yes — drop the image in and choose data URI. You get the complete `data:image/png;base64,…` string with the right media type already filled in, ready to paste into a stylesheet, an <img> tag or an email template.
Is there a size limit?
Available memory, rather than a fixed size cap, and it is generous — files of many megabytes encode fine. Encoding is done in chunks specifically to handle large files; the obvious implementation crashes at around 125 KB with "Maximum call stack size exceeded", which is a bug in a great many online encoders.
Good to know: Base64 makes data about 33% larger — that is the format, not a fault. Files are read into memory whole, so a very large file can exhaust a phone's tab before it finishes. Line wrapping is off by default; email and PEM formats expect it on.
Put this tool on your website
Free for any blog, class page or help article. Paste one snippet and your visitors can use it right on your page.