Base64 Encoder and Decoder

[ BASE64 ]
TWFidWhheSEg4oKxMSwyMzQuNTY=
Bytes in20
Characters out28
Overhead+40%

The classic alphabet. Percent-encode it before putting it in a URL.

18 characters is 20 bytes in UTF-8 — anything outside plain ASCII takes two to four bytes each.
[ WHAT THIS IS ]

Base64 rewrites arbitrary bytes using 64 printable characters, so they can travel through something that only carries text — a URL, an email header, a JSON string, an HTML attribute.

Text is converted to UTF-8 bytes first, and the bytes are what get encoded. That is what every other implementation means by "Base64 of a string", and it is why the peso sign, ñ and emoji all survive here. The browser function most online tools are built on top of is Latin-1 only: it throws an error on anything above U+00FF, and ₱ is U+20B1.

Decoding runs the same way in reverse, with one refusal. If the bytes are not valid UTF-8 — because you pasted an image, or a compressed file — the page will not render them as text. A lenient decoder turns them into a row of replacement characters, which looks like an answer and is not one. You get the byte count and a hex preview instead.

[ QUESTIONS ]

Is Base64 encryption?

No, and this is the mistake that matters. Base64 is a way of writing bytes using 64 printable characters so they survive a channel that only carries text — an email header, a data URL, a JSON string. Anyone can decode it in a second, including on this page. Never use it to hide a password, an API key or anything else you would not publish.

Why did my ₱ sign break in another tool?

Because it was encoded as Latin-1 rather than UTF-8. The peso sign is one character but three bytes, and the browser function most tools are built on refuses anything above 255 outright. This encodes the UTF-8 bytes, so ₱, ñ, Baybayin and emoji all survive a round trip intact.

What is the difference between the two alphabets?

Only the last two characters. Standard Base64 uses + and /, which both have a meaning inside a URL and have to be escaped. The URL-safe alphabet uses - and _ instead so the result can be dropped into a link or a filename untouched. Nothing else changes, and this page decodes either without being told which.

Why is my encoded text a third longer?

Because three bytes are rewritten as four characters. That is a 33% increase, plus up to two padding characters. It is the price of using only characters that survive being copied, pasted and emailed.

Can I paste something with line breaks in it?

Yes. Email attachments wrap Base64 at 76 characters a line, and copying from a terminal adds its own breaks. Whitespace is ignored on decoding, and the page tells you when it ignored some.

It says my bytes are not text. What does that mean?

You have decoded something that was never text — an image, a PDF, a compressed file. Rather than show you a row of replacement characters that looks like a broken answer, the page shows the byte count and the first bytes in hex so you can see what it actually is.

[ HOW IT ENCODES ]
Three bytes become four characters
M a n 3 bytes = 24 bits
010011 010110 000101 101110 4 groups of 6
T W F u 4 characters
[ WHY THE = SIGNS ]

Six bits do not divide into eight evenly, so a length that is not a multiple of three leaves a partial group. The padding says how many bytes the last group really held: one = means two bytes, two means one. Some systems drop them, so the page decodes with or without.

[ WORKED EXAMPLE ]
f Zg==
fo Zm8=
foo Zm9v
4oKx

The first three are the RFC 4648 test vectors. The fourth is one character and three bytes, and it is the one that breaks a Latin-1 encoder.

[ NEXT ]
43JSON FormatterValidate and tidy a document, with the error located
42Password GeneratorCryptographic randomness, entropy reported honestly
41QR Code GeneratorEncode a link or Wi-Fi details as a scannable code
39Unit ConverterLength, weight, temperature and four more
[ IMPORTANT ]

Base64 is an encoding, not encryption — anything you encode here can be read by anyone who sees it. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.