Hex to Base64

Paste hex bytes and get Base64 as you type. Spaces, colons, commas and 0x prefixes are ignored, and URL-safe output is one click away.

0 bytes
0 chars

Everything runs in your browser. Your text and files are never uploaded.

How to convert hex to Base64

  1. Paste the hex bytes into the left box. Input is hex bytes is already ticked on this page.
  2. Use any common format. 48656c6c6f, 48 65 6c 6c 6f, 48:65:6c:6c:6f and 0x48 0x65 0x6c all give the same result. Upper and lower case both work.
  3. 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:

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.

Frequently asked questions

How do I convert hex to Base64?

Paste the hex into the left box with Input is hex bytes ticked. Each pair of hex digits is read as one byte and the Base64 of those bytes appears on the right.

Why is my hex input rejected?

Either it has a character other than 0-9 and a-f, or it has an odd number of digits. Every byte needs exactly two hex digits, so 0f is valid but f on its own is not.

How do I convert Base64 back to hex?

Switch to Decode, paste the Base64 string and tick Show decoded output as hex. The bytes are shown as space-separated hex pairs.

Is converting hex to Base64 the same as encoding the hex text?

No. Converting reads 48656c6c6f as the five bytes of Hello and gives SGVsbG8=. Encoding the hex as text would encode the ten characters themselves and give a much longer, different result.