Base64 encode/decode · Guide

Base64 Decoder to Hex: Convert Base64 to Hexadecimal

Converting Base64 to hex is how you look at what a payload actually contains. Both are just ways of writing the same bytes — hex shows them one at a time, which is what you want when the content is not text.

Why hex rather than text

Decoding Base64 to text only helps if the bytes were text. When they are an image, a certificate or a compressed stream, text output is unreadable noise while hex shows the exact byte values.

Hex is also the format checksums, cryptographic keys and binary protocol dumps use, so converting into it lets you compare against documentation directly.

Identifying content from the first bytes

The opening bytes usually name the format. Convert to hex and check the start against these magic numbers:

Text
25 50 44 46        %PDF   -> PDF
89 50 4E 47        .PNG   -> PNG image
FF D8 FF                  -> JPEG image
50 4B 03 04        PK..   -> ZIP (also docx, xlsx, jar, apk)
1F 8B                     -> gzip
30 82                     -> DER certificate or key

This turns "what is this blob?" into a two-second question, which is usually the real reason for converting in the first place.

Doing the conversion

Shell
# shell
printf %s 'iVBORw0KGgo=' | base64 -d | xxd -p

# PHP
bin2hex(base64_decode($b64));

# Python
import base64
base64.b64decode(s).hex()

Both directions are lossless re-encodings of the same bytes — nothing is interpreted along the way.

Frequently asked questions

How much longer is hex than Base64?

Hex is 2 characters per byte, Base64 about 1.33 — so hex output is roughly 50% longer.

Can I convert hex back to Base64?

Yes. Decode the hex to bytes and Base64-encode them; the round trip is exact.

My hex starts with 504B — what is it?

A ZIP container. That covers .zip as well as .docx, .xlsx, .jar and .apk files.

Ready to try it?

Open the free browser-based Base64 encode/decode and apply what you just read — no sign-up, runs locally.

Open the Base64 encode/decode tool