Base64 to Hex Converter
Convert Base64 encoded strings to hexadecimal and hex to Base64 instantly. Supports formatting, file upload, copy, and download.
About
Base64 encoding represents binary data using 64 ASCII characters (A - Z, a - z, 0 - 9, +, /) plus padding (=). Every 3 input bytes become 4 Base64 characters, inflating size by roughly 33%. Hexadecimal uses 16 symbols (0 - 9, A - F) and maps each byte to exactly 2 characters. Misinterpreting the encoding scheme during protocol debugging, firmware flashing, or cryptographic key exchange corrupts payloads silently. This tool decodes Base64 to its raw byte sequence, then emits each byte as a hex pair. It also reverses the process. It assumes standard Base64 (RFC 4648); URL-safe variants (- and _) should be replaced before conversion.
Formulas
Base64 encodes every group of 3 bytes (24 bits) into 4 printable characters. The conversion from a Base64 string to hex proceeds in two stages: decode, then format.
Where n is the byte length of the decoded data. Each byte value ranges from 0x00 to 0xFF. The output length in hex characters is exactly 2n.
The reverse operation parses hex pairs back to byte values and re-encodes via btoa:
The output size ratio: Base64 is approximately 43 the size of raw bytes, while hex is exactly 2× the byte count.
Reference Data
| ASCII Character | Decimal | Hex | Binary | Base64 Index |
|---|---|---|---|---|
| A | 65 | 41 | 01000001 | 0 |
| B | 66 | 42 | 01000010 | 1 |
| Z | 90 | 5A | 01011010 | 25 |
| a | 97 | 61 | 01100001 | 26 |
| z | 122 | 7A | 01111010 | 51 |
| 0 | 48 | 30 | 00110000 | 52 |
| 9 | 57 | 39 | 00111001 | 61 |
| + | 43 | 2B | 00101011 | 62 |
| / | 47 | 2F | 00101111 | 63 |
| = | 61 | 3D | 00111101 | Padding |
| NUL | 0 | 00 | 00000000 | - |
| LF | 10 | 0A | 00001010 | - |
| CR | 13 | 0D | 00001101 | - |
| Space | 32 | 20 | 00100000 | - |
| DEL | 127 | 7F | 01111111 | - |
| Å (byte 0xC5) | 197 | C5 | 11000101 | - |
| μ (byte 0xB5) | 181 | B5 | 10110101 | - |
| 0xFF | 255 | FF | 11111111 | - |
| 0x80 | 128 | 80 | 10000000 | - |
| 0x0F | 15 | 0F | 00001111 | - |