How Base64 turns 3 bytes into 4 characters
Base64 reads your data 3 bytes (24 bits) at a time and cuts it into four 6-bit groups. Each group picks one of 64 characters. That is why the output is about 33% larger than the input.
| Text | M | a | n | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Byte | 77 | 97 | 110 | |||||||||
| Bits | 010011 | 010110 | 000101 | 101110 | ||||||||
| Index | 19 | 22 | 5 | 46 | ||||||||
| Base64 | T | W | F | u | ||||||||
When the input length is not a multiple of 3, the last group is filled with zero bits and the output is padded with one or two = characters.
What this page handles
- UTF-8 text, so Hangul, kanji and emoji survive a round trip.
- URL-safe Base64 (
-and_in place of+and/) and input with missing=padding. - data: URIs. Paste the whole thing and the header is skipped for you.
- PNG, JPEG, GIF, WebP and SVG are previewed. JSON is indented. JWTs show header and payload.
- Text that was encoded two or more times is decoded all the way down, and the chip shows how many layers there were.
- Links in the decoded text are listed as links you can open. Several Base64 strings on separate lines are decoded line by line.
- Files. Choose a file to get its Base64, for example to embed a small image in CSS.
Standard and URL-safe Base64
The standard alphabet ends with + and /. Both have a meaning inside URLs, so RFC 4648 defines a second alphabet that uses - and _ and usually drops the padding. JWTs use that variant. This page decodes either one without asking, and encodes to the URL-safe form when you tick the option.
Questions
Is Base64 encryption?
No. Anyone can decode it. Use it to move bytes through text-only channels, not to hide them.
Is my token sent to a server?
No. The conversion is done by JavaScript on this page. You can turn off your network connection and it still works.
Why does decoding fail with “not allowed in Base64”?
Base64 allows only A to Z, a to z, 0 to 9, + and / (or - and _), plus = at the end. The message shows the first character that does not fit and where it is. A stray quote or a truncated copy is the usual cause.
Why is my decoded text unreadable?
The bytes are probably not UTF-8 text. The page then reports binary data and shows the first bytes in hex, which is often enough to recognise a file type.