Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Hex to Base64 Converter

Convert hexadecimal strings to Base64 encoding and back — supports 0x prefixes, spaced hex, and auto-validation

Your files never leave your browser
Hex → Base64
Hex Input0 chars
Base64 Output0 chars
Ready·0 bytes

Paste any hex string — spaced, colon-separated, 0x-prefixed, doesn't matter — and get the Base64 equivalent in one shot. Works in reverse too: hit Swap and decode Base64 back to hex. And everything runs in your browser. Nothing gets uploaded.

How It Works

Hex String
➔
Parse to Bytes
➔
Base64 Encode

The converter strips separators and prefixes from your hex, then groups every two characters into a byte. Those raw bytes get fed into a standard Base64 encoder (RFC 4648), which maps every 3 bytes to 4 ASCII characters. If the byte count isn't divisible by three, padding characters (=) fill the gap.

Examples

Simple Text Encoding

Converting the hex representation of "Hello World" to Base64 for embedding in a JSON payload.

INPUT
48656c6c6f20576f726c64
OUTPUT
SGVsbG8gV29ybGQ=

SHA-256 Hash for an API Header

Your HMAC library outputs a hex digest, but the API wants Base64 in the Authorization header. Classic.

INPUT
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
OUTPUT
47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=

Spaced Hex from a Packet Capture

Wireshark gives you space-separated hex. You need Base64 for a bug report attachment field. Just paste it as-is.

INPUT
50 4b 03 04 14 00 00 00
OUTPUT
UEsDBBQAAAA=

Who Uses This

💻 Backend Developers

Encoding HMAC digests and encryption keys into Base64 for API authentication headers.

🔒 Security Engineers

Converting certificate fingerprints and hash values between formats during audits.

📡 Network Analysts

Turning packet capture hex dumps into Base64 for logs and reports.

📚 Students

Checking homework answers for cryptography and networking assignments.

Common Mistakes

Odd number of hex characters

Hex encodes bytes, and each byte needs exactly two hex digits. If you have an odd count (like 48656c6c6f2), the last nibble is ambiguous. Add a leading zero or check for a missing character.

Pasting the "0x" prefix from code

Lots of programming languages print hex values like 0x4A. This tool handles that automatically, but some other tools don't. If you get weird results elsewhere, strip the prefixes first.

Confusing hex-encoded text with raw hex bytes

If you paste the ASCII text "48656c6c6f" into a Base64 encoder directly, you get the Base64 of those literal characters — not the Base64 of the bytes they represent. This tool treats your input as hex values, which is what you almost always want.

Technical Details

Frequently Asked Questions

What's the difference between hex and Base64?

Hex uses 16 symbols (0–9, A–F) and needs 2 characters per byte. Base64 uses 64 symbols and packs 3 bytes into 4 characters. So Base64 is roughly 33% shorter than hex for the same data. Both represent the exact same binary underneath — it's just a different way of writing it down.

Why do APIs prefer Base64 over hex?

Mostly size. A 32-byte encryption key is 64 characters in hex but only 44 in Base64. When you're cramming binary data into JSON, HTTP headers, or XML, those saved bytes add up. Base64 is also the standard for MIME email, JWTs, and data URIs, so many systems expect it by default.

Can I convert Base64 back to hex here?

Yes. Hit the Swap button between the two panels. The tool flips direction, so you paste Base64 on the left and get hex on the right. It's the same converter running in reverse.

Is it safe to paste private keys or tokens?

As safe as your own computer. The conversion happens entirely in JavaScript inside your browser tab. No data gets sent anywhere — you can disconnect from the internet and it still works. That said, be careful pasting secrets on shared or public machines.

What happens if my hex string has an odd number of characters?

You'll see an error. Hex works in pairs — two characters equal one byte. An odd count means something got cut off or there's a typo. Double-check your source, or add a leading zero if the first byte is supposed to be a small value (like 0a instead of just a).

Share: