How to convert Hex to Base64
Hex and Base64 both describe raw bytes, just with different alphabets: hex
uses two characters per byte (4 bits each), Base64 uses four characters per three
bytes (6 bits each). To convert, the hex digits are first paired back into bytes,
then those bytes are regrouped into 6-bit chunks and read off the Base64 alphabet.
Because the group sizes differ, a partial final group produces the familiar
= padding.
Worked example
Take the four bytes de ad be ef.
- As 32 bits:
11011110 10101101 10111110 11101111. - Regroup into 6-bit values (the last group is short, so it is zero-padded):
110111 101010 110110 111110 111011 11. - Reading off the alphabet gives
3q2+7w==— the two=signs mark the padding of that short final group.
Decoding runs the same steps backwards, recovering the original four bytes exactly.
The Base64 alphabet
| Value | Character |
|---|---|
| 0 | A |
| 1 | B |
| 2 | C |
| 3 | D |
| 4 | E |
| 5 | F |
| 6 | G |
| 7 | H |
| 8 | I |
| 9 | J |
| 10 | K |
| 11 | L |
| 12 | M |
| 13 | N |
| 14 | O |
| 15 | P |
| 16 | Q |
| 17 | R |
| 18 | S |
| 19 | T |
| 20 | U |
| 21 | V |
| 22 | W |
| 23 | X |
| 24 | Y |
| 25 | Z |
| 26 | a |
| 27 | b |
| 28 | c |
| 29 | d |
| 30 | e |
| 31 | f |
| 32 | g |
| 33 | h |
| 34 | i |
| 35 | j |
| 36 | k |
| 37 | l |
| 38 | m |
| 39 | n |
| 40 | o |
| 41 | p |
| 42 | q |
| 43 | r |
| 44 | s |
| 45 | t |
| 46 | u |
| 47 | v |
| 48 | w |
| 49 | x |
| 50 | y |
| 51 | z |
| 52 | 0 |
| 53 | 1 |
| 54 | 2 |
| 55 | 3 |
| 56 | 4 |
| 57 | 5 |
| 58 | 6 |
| 59 | 7 |
| 60 | 8 |
| 61 | 9 |
| 62 | + |
| 63 | / |
Frequently asked questions
- How do I convert Base64 back to Hex?
- Use the Base64 to Hex converter, or just type into the matching pane above — every pane is editable and the others update to match.
- Is my data sent to a server?
- No. All encoding and decoding happens in your browser, so you can safely convert tokens, keys, or anything else sensitive.
- Does this handle non-ASCII text?
- Yes. Text is encoded as UTF-8, so accented letters, emoji, and non-Latin scripts convert correctly — the hex pane always shows you the exact bytes.