Base64 Converter
Encode text and files to Base64, in the standard or the URL-safe alphabet, and decode Base64 back to text or to the exact bytes it stands for.
Overview
Base64 writes any data with 64 printable characters, so it can travel through systems that only carry
text: e-mail, JSON, HTML, configuration files. Every 3 bytes become 4 characters. The standard alphabet of RFC
4648 is A to Z, a to z, 0 to 9,
+ and /, with = as padding at the end. The URL-safe alphabet from the
same RFC uses - and _ instead of + and /, which have a
meaning in addresses and file names, and usually leaves the padding out.
Base64 is an encoding, not encryption. Anyone can decode it; there is no key.
Web interface
Paste text or Base64 into the input; the output updates as you type. Auto works out the direction by itself, Encode and Decode fix it. Alphabet chooses Standard or URL-safe for encoding and is hidden in Decode, because decoding accepts both.
Upload file, or a file dropped onto the input, encodes that file: the output holds its
Base64, and a Data URI with the file's type appears below it, with its own copy button.
Download saves the current result as base64.txt, decoded.txt, or,
for binary data, as decoded. followed by the file type. Clear empties everything
and returns to Auto and Standard. Ctrl/⌘ + Enter runs the conversion again.
How Auto decides
Many ordinary strings consist of Base64 characters only: every word of four, eight or twelve letters is valid Base64, and so is a hexadecimal hash. Auto therefore goes by what the input would decode to, in this order:
| Input | Auto |
|---|---|
starts with a data:…;base64, prefix, or contains a PEM block | decodes |
| contains anything that is not Base64: a space, a comma, punctuation | encodes |
| decodes to readable UTF-8 text | decodes |
| is at least 64 characters long, mixes upper and lower case and uses 20 or more different characters | decodes, as binary data |
| anything else | encodes |
So test is encoded to dGVzdA== although it is valid Base64, because it would
decode to three bytes that are not text. SGVsbG8 is decoded to Hello, padding or
not. When Auto guesses wrong, Encode and Decode settle it.
What decoding accepts
Base64 rarely arrives as one clean line. Decoding accepts it in the forms it is found in:
- behind a data URI prefix such as
data:image/png;base64,, with or without further parameters - inside a PEM block, between
-----BEGIN CERTIFICATE-----and the matching-----ENDline - broken into lines, as e-mail and PEM wrap it every 64 or 76 characters; all whitespace is ignored
- in the URL-safe alphabet, with
-and_ - without the
=padding
Encoding writes one unbroken line, in the alphabet selected.
Binary data
What decodes to valid UTF-8 text is shown as text. Anything else, bytes that are not UTF-8 or text with
control characters other than tabs and line breaks, is binary data. It is not shown, because showing bytes as
text changes them; the line under the output gives its size and type, and Download saves the
exact bytes. /w== downloads as the single byte FF.
| Recognised by its first bytes | Downloaded as |
|---|---|
| PNG image | decoded.png |
| JPEG image | decoded.jpeg |
| GIF image | decoded.gif |
| WebP image | decoded.webp |
| PDF document | decoded.pdf |
| ZIP archive | decoded.zip |
| gzip data | decoded.gz |
| contents of a PEM block | decoded.der |
| anything else | decoded.bin |
Errors
Input that is not Base64 is not decoded. The output stays empty and the line under it says why:
| Message | Meaning |
|---|---|
"*" is not a Base64 character | The input contains a character outside both alphabets, named in the message. |
= may only appear at the end, as padding | An = in the middle, as when two Base64 strings were joined. |
the length does not fit Base64, one character is missing or extra | One character too many or too few: no valid Base64 has a length of 4n + 1. |
No API
There is no API for this tool. Encoding and decoding run in the browser; in a script, use the Base64
support of the language at hand, such as base64 on the command line.
Limits
Files can be up to 10 MB. Pasted text has no limit.
Converting is fast: ten megabytes take under 0.2 seconds in every browser tested. Drawing that much text in the input and output fields is what takes time, and it depends on the browser and the characters. For 10 MB of plain ASCII it took about a second in Chrome and Firefox and 6 to 11 seconds in Safari's engine. Text with accents or emoji is much slower to draw in Chrome: 10 MB of it took 30 to 50 seconds there.
Privacy
Nothing leaves the browser. Files are read locally, the conversion runs on the page, and downloads are created on the spot. Nothing is stored, and Copy writes to the clipboard only when you press it.