Input

Mode:

Output

What Is Hex to Base64?

Hexadecimal is the format you see everywhere in debugging: memory dumps, cryptographic hashes, color codes, byte sequences in network packets. Base64 (RFC 4648) is what APIs, JWTs, email attachments, and data URIs use to transport binary data safely over text-based channels. This tool converts in both directions: paste hex bytes and get Base64, or paste Base64 and get the hex representation back. Everything runs locally in your browser using btoa() and atob(): nothing leaves your machine.

Encode mode (Hex → Base64) is the default. Toggle to Decode (Base64 → Hex) when you need to reverse the operation. Hex input can include spaces between bytes: they are stripped automatically.

How to Use This Tool

1

Choose Mode

Stay in Encode when you are holding hex, such as a digest from md5sum or sha256sum. Switch to Decode when you have Base64 (a full data: URI is fine) and want to see the raw bytes behind it.

2

Paste Input

Paste the hex into the left editor. Spaces and line breaks between bytes are ignored, but a 0x prefix or colons are not, so remove those first. Sample loads an MD5 checksum in Encode mode and a short Base64 string in Decode mode; Upload reads a .txt or .hex file into the editor.

3

Copy or Download Result

The Base64 on the right refreshes as soon as the hex changes. Copy takes it to the clipboard; Download stores it in a file.

Example

The MD5 checksum md5sum printed for a one-line invoice CSV, rewritten as the Base64 value a Content-MD5 header expects:

Hex Input

Input

Base64 Output

Output

Frequently Asked Questions

How does hex to Base64 encoding work?

Each pair of hex digits represents one byte. The encoder reads the hex string two characters at a time, converts each pair to its byte value using parseInt(hex, 16), builds a binary string, then encodes it with the browser's btoa() function. The result follows the standard Base64 alphabet defined in RFC 4648.

Does the hex input need spaces between bytes?

No. You can paste hex with or without spaces, because all whitespace is stripped before processing. Both 48656c6c6f and 48 65 6c 6c 6f produce the same output. Colons are not removed, though: a MAC-style c3:df:36 fails the hex check, so delete them first.

Can I paste a Data URI (data:...;base64,...) when decoding?

Yes. When decoding Base64 → Hex, the tool automatically strips the data: prefix and MIME type, so you can paste a full Data URI directly without editing it first.

Why does encoding fail with an odd-length hex string?

Each byte in hexadecimal requires exactly two characters. If your input has an odd number of hex characters, the last byte is incomplete and the encoder cannot proceed. Strip any 0x prefix, spaces, or colons, and make sure the total character count is even.

Is my data private?

Yes. Hex pairs are turned into bytes with parseInt and handed to btoa() inside this tab, with no request behind it. That matters on this page, because the hex people paste here is often a key, a token or the digest of something private. Keep the Network tab open while you type if you want to watch it stay quiet.

Is the output URL-safe Base64?

Standard Base64 uses +, /, and = padding. Base64url swaps + for - and / for _, so the string can sit inside a URL without percent-encoding. This tool produces standard Base64. For URL-safe variants use our Base64 URL Encoder.

Related Tools

The alphabet and padding rules this page follows are in section 4 of RFC 4648. For why two hex digits always make exactly one byte, the hexadecimal article on Wikipedia is a short read, and MDN's Base64 glossary entry covers btoa() and its quirks.