Base64 encoder and decoder
Encode text to Base64 or decode it back, with a URL-safe option and UTF-8.
Result
More octal, code points
Settings
Recent
Base64 writes any bytes using 64 safe characters: every 3 bytes become 4 characters, and = fills the end when bytes run short. Paste text to encode it, or paste Base64 to read it back as UTF-8 text; the URL-safe form uses - and _ in place of + and /. Free to use, nothing to register.
How to do it by hand
- Turn the text into bytes, usually with UTF-8.
- Take the bytes three at a time, which gives 24 bits.
- Split the 24 bits into four 6-bit pieces and look each one up in the 64-character table.
- If the last group has only one or two bytes, add = or == at the end.
Worked examples
Man
4D 61 6E → 010011 010110 000101 101110 → 19, 22, 5, 46
TWFu
ab
61 62 → 011000 010110 001000 → 24, 22, 8, then one =
YWI=
안녕 (UTF-8)
EC 95 88 EB 85 95 → two groups of three bytes
7JWI64WV
Common mistakes
- Treating Base64 as encryption. Anyone can decode it, so it hides nothing.
- Decoding URL-safe Base64 as the standard form. If you see - or _, turn on the URL-safe option.
- Ignoring the text encoding. The same word gives different Base64 in UTF-8 and in EUC-KR.
The 64 Base64 characters
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| 6 | G | 22 | W | 38 | m | 54 | 2 |
| 7 | H | 23 | X | 39 | n | 55 | 3 |
| 8 | I | 24 | Y | 40 | o | 56 | 4 |
| 9 | J | 25 | Z | 41 | p | 57 | 5 |
| 10 | K | 26 | a | 42 | q | 58 | 6 |
| 11 | L | 27 | b | 43 | r | 59 | 7 |
| 12 | M | 28 | c | 44 | s | 60 | 8 |
| 13 | N | 29 | d | 45 | t | 61 | 9 |
| 14 | O | 30 | e | 46 | u | 62 | + |
| 15 | P | 31 | f | 47 | v | 63 | / |
URL-safe Base64 uses - for 62 and _ for 63, and usually drops the = padding.
Questions people ask
Why is Base64 longer than the original?
Every 3 bytes become 4 characters, so the result is about a third longer.
Can I leave out the = at the end?
Some systems drop it, especially in URL-safe tokens. Strict decoders may still need it, so keep it unless you know the other side accepts it without.
Why does my decoded text look broken?
The bytes inside were probably not UTF-8 text, or the Base64 was cut short. Check that you copied the whole string.