About Hex to Base64 Conversion
Hex to Base64 conversion is commonly used when working with cryptographic outputs, binary data, hashes, and API payloads. Many security libraries and tools return values in hexadecimal format, while modern web APIs and tokens often use Base64 encoding. This online Hex to Base64 converter helps you quickly convert hex strings to Base64 and Base64 back to hex for debugging, integration, and data transport.
If you are generating hashes or checksums, you can use the OpenSSL Hash Generator to produce hash values and then encode them using this Hex ↔ Base64 tool when integrating with APIs or headers.
When working with tokens and authentication, Base64 encoding is widely used in JWTs. You may also find our JWT Decoder helpful to inspect token payloads alongside this converter.
For encryption workflows that output binary or hex data, explore our cryptography tools collection which includes AES, RSA, and modern encryption utilities that pair well with Hex and Base64 encoding.
This Hex to Base64 converter runs entirely in your browser and does not store or transmit your data. It’s a simple way to encode, decode, and debug hexadecimal and Base64 values online.
Command Line and Code Examples
Converting Hex to Base64
In Bash using xxd and base64:
echo -n "48656c6c6f20576f726c64" | xxd -r -p | base64
In Python:
import base64
hex_str = "48656c6c6f20576f726c64"
b64_str = base64.b64encode(bytes.fromhex(hex_str)).decode("ascii")
print(b64_str) # SGVsbG8gV29ybGQ=
In Node.js:
const hex = "48656c6c6f20576f726c64";
const b64 = Buffer.from(hex, "hex").toString("base64");
console.log(b64); // SGVsbG8gV29ybGQ=
Converting Base64 to Hex
In Bash using base64 and xxd:
echo -n "SGVsbG8gV29ybGQ=" | base64 -d | xxd -p
In Python:
import base64
b64_str = "SGVsbG8gV29ybGQ="
hex_str = base64.b64decode(b64_str).hex()
print(hex_str) # 48656c6c6f20576f726c64
In Node.js:
const b64 = "SGVsbG8gV29ybGQ=";
const hex = Buffer.from(b64, "base64").toString("hex");
console.log(hex); // 48656c6c6f20576f726c64
Frequently Asked Questions
What is the difference between Hex and Base64 representation size?
Hexadecimal represents each byte with 2 characters (each char represents 4 bits, a 100% overhead compared to binary). Base64 represents every 3 bytes using 4 characters (each char represents 6 bits, ~33% overhead). Therefore, a Base64 string is approximately 33% shorter than the equivalent Hex string.
Does whitespace in the input cause errors?
No. Both spaces and line breaks are automatically stripped prior to validation and conversion, allowing easy copy-pasting of formatted blocks.
Why must Hex strings have an even length?
In hexadecimal encoding, each byte of binary data consists of exactly two hex nibbles (digits 0–9, a–f). An odd number of hex characters indicates an incomplete byte.
Is this conversion safe for confidential secrets or keys?
Yes. The tool runs 100% locally in your web browser. Neither the input hex/Base64 strings nor the conversion results are transmitted to any server.
❤️ Liked this tool?
If it saved you time, consider buying me a coffee to support future improvements.