Base64 encoder and decoder
Text to Base64 and back again. With real UTF-8, which is where half the home-made implementations fall over.
Your figures
Result
SGVsbG8sIGphbGFwZcOxbyDwn5GL - Characters in the result
- 28
- Input (bytes)
- 21
- Output (bytes)
- 28
- How much it grows
- 33.3%
What we assume
- Everything happens in your browser. Neither the text nor the result leaves your machine.
- Text is encoded as UTF-8 before going to Base64. Without that step, anything outside ASCII breaks.
- Base64 is not encryption. It is a way of writing bytes with 64 printable characters: anyone can undo it with no key at all.
- When decoding, the result must be valid UTF-8 text. If the Base64 held an image or a binary, it cannot be shown here.
- Input without padding, and with spaces or line breaks, is accepted: it is cleaned before decoding.
How it is calculated
Base64 takes bytes three at a time and rewrites them as four characters from a 64-symbol alphabet. Hence the name, and hence the result always taking a third more room than the input: four characters for every three bytes.
The step almost everyone skips
The browser's btoa does not accept text: it accepts bytes dressed as a string,
and fails on anything above U+00FF. A single «ñ» breaks it. Here the text is converted to
UTF-8 first, which is why accents and emoji come back whole.
The URL-safe variant
The normal alphabet uses + and /, and both mean something else
inside an address. The URL-safe variant swaps them for - and _ and
drops the = padding. It is what JWTs use and what you need if the result goes
into a parameter.
Not a security measure
Seeing something in Base64 does not mean it is protected. It is encoding, not encryption: there is no key, and undoing it is exactly as easy as doing it.
An example
Hello becomes SGVsbG8=. With accents you can see why the UTF-8
step matters: jalapeño is 9 bytes, not 8, which is why its Base64 is longer than
the letters suggest.
Frequently asked questions
Does Base64 hide anything?
No. It is encoding, not encryption: there is no key and anyone undoes it in a second. If you need something unreadable, it has to be properly encrypted.
Why is the result longer than the text?
Because every three bytes become four characters. The growth is a third, roughly 33%, and you can see it in the «how much it grows» figure.
Can I decode an image in Base64?
It can be decoded, but not shown here: this tool works with text. If the content is not valid UTF-8 we say so rather than showing you broken characters.
What is the URL-safe variant?
The same encoding with two characters swapped — - and _ instead of + and / — and no padding, so the result can sit inside an address without breaking it. It is what JWTs use.
Keep calculating
All tools →- URL encoder and decoder For putting text into an address without breaking it. The difference between encoding a value and encoding a whole URL is the bit that usually goes wrong.
- Character, word and byte counter Characters, words, lines and bytes. Counted properly: an emoji is one character, whatever your editor says.
- JWT decoder Paste the token and see what is inside. Note: this decodes it, it does not verify it — checking the signature needs the key.
Updated on 2026-09-02. Calculations run in your browser; nothing you type is sent to a server.