How to convert hex to Base64
- Paste the hex bytes into the left box. Input is hex bytes is already ticked on this page.
- Use any common format.
48656c6c6f,48 65 6c 6c 6f,48:65:6c:6c:6fand0x48 0x65 0x6call give the same result. Upper and lower case both work. - Copy the Base64 from the right. Tick URL-safe and Remove = padding if you need Base64URL, for example for a JWT or a URL.
The example loaded in the tool is the hex for Hello, Base64.
Hex to Base64 examples
| Hex | Base64 | What it is |
|---|---|---|
48 65 6c 6c 6f |
SGVsbG8= |
The text "Hello" |
00 ff |
AP8= |
Two bytes, 0 and 255 |
fb ff fe |
+//+ |
Bytes that show the + and / characters |
89 50 4e 47 |
iVBORw== |
The start of every PNG file |
Why convert hex to Base64?
Hex and Base64 are two ways of writing the same bytes as text. Hex uses two characters per byte, so it is easy to read one byte at a time but doubles the size. Base64 uses four characters for every three bytes, about 33% overhead, so it is much more compact. Converting does not change the data, only how it is written.
You run into this when one tool gives you hex and another expects Base64:
- Hashes and keys.
sha256sumand most hash tools print hex, while HTTP headers such asContent-MD5, Subresource Integrity (sha384-...) and many signing APIs expect the same digest in Base64. - Cryptography. AES keys, IVs and HMAC secrets are often generated or logged as hex but configured as Base64.
- Binary in JSON. A byte array from a debugger or packet capture, shown as hex, has to be Base64 to go into a JSON field.
Converting hex is not the same as encoding hex text
This is the most common mistake. If you paste 48656c6c6f into a normal text encoder, it encodes the ten characters 4, 8, 6, 5 and so on, and gives NDg2NTZjNmM2Zg==. That is the Base64 of the hex text, not of the bytes. The correct conversion reads every pair of digits as one byte and gives SGVsbG8=. On this page, Input is hex bytes does the second; untick it to get the first.
Base64 back to hex
To go the other direction, click Decode, paste the Base64 and tick Show decoded output as hex. The bytes are shown as space-separated pairs, which is handy for checking a hash or a key by eye. For general text encoding, use the main Base64 encoder; for the difference between the formats, see URL safe Base64.