Hex to Base64 Converter
Convert a hexadecimal string into Base64. The parser accepts spaces, colons, dashes, 0x and \x prefixes, so you can paste hex from almost any source without cleaning it up first.
The reverse is the Base64 to Hex Converter, and the textual form of the same bytes comes from the Hex to Text Converter. For binary image data, the Image to Base64 Converter is the sibling.
How to use the Hex to Base64
- 1 Paste a hexadecimal string into the box — spaces, colons and 0x prefixes are tolerated.
- 2 The Base64 equivalent appears immediately, padded correctly to a multiple of four characters.
- 3 Check the byte count shown alongside, which confirms the hex was read as whole bytes.
- 4 Copy the result, or paste it into Base64 to Hex to reverse the conversion.
Hexadecimal to compact Base64 encoding
The Hex to Base64 converter transforms raw hexadecimal byte strings into compact Base64 ASCII characters. Because each hexadecimal character represents only 4 bits (a nibble) while each Base64 character represents 6 bits, this transformation yields an immediate 33% reduction in character length.
This encoding conversion is widely utilized when embedding cryptographic hashes, authentication tokens, or binary identifiers into HTTP authorization headers, JSON payloads, or URL query parameters where compact ASCII formatting is required.
- Shrinks 2-character hex byte representations into compact 4-character Base64 blocks.
- Produces safe ASCII strings for inclusion in JSON, XML, and HTTP headers.
- Validates hex inputs for even length and valid 0-9 and A-F character ranges.
- Essential for preparing cryptographic signatures and binary digests for transport.
How It Works
All non-hexadecimal characters are stripped, then the remaining nibbles are paired into bytes and encoded as Base64. Odd-length input is rejected so you always get a clean result.
- Ignores spaces, colons, dashes, 0x and \x
- Standard or URL-safe Base64 output
- Optional padding for URL-safe mode
- ASCII preview and byte count
- Live validation of hex input
Frequently asked questions
What happens if my hex has an odd number of digits?
It cannot be read as whole bytes, so the tool reports it as invalid rather than guessing. Add a leading zero or remove the stray digit — an odd-length hex string almost always means a copy-paste error.
Can I paste hex with colons, like a MAC address?
Yes. Colons, hyphens, spaces and "0x" prefixes are all stripped before conversion, so pasting a MAC address or a dump straight from a debugger works without manual cleanup.
Why is Base64 shorter than the hex string?
Hex spends two characters per byte; Base64 spends roughly four characters per three bytes. That is why Base64 is about 33% larger than the raw data while hex is 100% larger — Base64 is the more compact of the two.
Related Developer Tools
You might also need
Tools from other categories that people pair with the Hex to Base64: