How to use
- Paste the Base64 string into the input. Base64 is preselected as the source and hex as the target.
- Read the hexadecimal output, two hex digits for every byte.
- Pick another target encoding, such as Base58 or Base32, if you need a different format, or press Swap to convert hex back to Base64.
- Copy the result.
Two ways to write the same bytes
Hex and Base64 both write binary data as text. Hex spends two characters on each byte, which makes individual byte values easy to read and compare. Base64 packs 3 bytes into 4 characters and is about a third shorter. Converting between them changes only the notation, never the data:
| Value | Bytes | Hex length | Base64 length |
|---|---|---|---|
| MD5 hash | 16 | 32 | 24 |
| SHA-1 hash | 20 | 40 | 28 |
| SHA-256 hash, Ed25519 public key | 32 | 64 | 44 |
| SHA-384 hash | 48 | 96 | 64 |
| SHA-512 hash, Ed25519 signature | 64 | 128 | 88 |
Hex is also what hex editors, packet analysers and debuggers display, so converting Base64 to hex lets you line the data up with what those tools show.
When you need hex from Base64
- Comparing hashes. Tools such as
sha256sumprint hex, while Subresource Integrity attributes, Content Security Policy hashes and checksum headers such asContent-MD5use Base64. Convert one side to compare them. - SSH fingerprints.
ssh-keygen -lprintsSHA256:fingerprints as unpadded Base64, while SSHFP DNS records store the same SHA-256 digest in hex. Paste the part afterSHA256:to get the hex form. - Keys, IVs and signatures. When debugging cryptographic code, seeing the bytes in hex makes it easy to check the length, compare values and spot a missing or extra byte.
Input the converter accepts
Spaces and line breaks in the Base64 input are ignored, the URL-safe characters - and _ are accepted, and = padding is optional, so values copied from JSON, JWTs or terminal output can be pasted as they are. The conversion works on the decoded bytes: the result is the hex of the data, not of the Base64 characters themselves. To see the hex codes of a piece of text, use Base16 instead.
# Shell
printf '%s' "$B64" | base64 --decode | xxd -p
# Python
base64.b64decode(s).hex()
// Node.js
Buffer.from(s, 'base64').toString('hex')
Frequently asked questions
Does this convert the Base64 text or the bytes it represents?
Why is the hex output longer than the Base64 input?
Hex needs 2 characters per byte, while Base64 needs about 1.33. A 32-byte SHA-256 digest is 44 characters in Base64 and 64 characters in hex.
How do I get uppercase hex or colon separators?
Can I convert Base64URL values from a JWT or JSON Web Key?
Yes. The URL-safe characters and missing padding are handled automatically, so key parameters and signatures can be pasted without changes.