Hex to Base64
Convert hexadecimal bytes to Base64 and Base64 back to hex.
Hex to Base64 Converter
Convert hexadecimal bytes to Base64 and Base64 back to hex. Hex and Base64 are the two most common ways to write binary data as text, and developers constantly switch between them when working with hashes, cryptographic keys, certificates, and network packets.
Typical conversions
- Hashes and integrity checks – tools like
sha256sumprint hex, but Subresource Integrity attributes, Content Security Policy hashes, and AWS or Azure checksum headers expect Base64. Paste the hex digest and get the Base64 form instantly. - Keys and secrets – AES keys, HMAC secrets, and random tokens generated with
openssl rand -hex 32often need to be stored in Base64 in config files, and vice versa. - Protocol debugging – packet captures and hex dumps show bytes in hex, while JSON APIs and message queues carry them as Base64.
- Blockchain and IDs – transaction payloads, UUID bytes, and MongoDB ObjectIds are regularly converted between both notations.
Example
The sample 48 65 6c 6c 6f is five bytes, the ASCII word Hello, and encodes to SGVsbG8=. A continuous string like 48656c6c6f gives the same result, and so does 0x48 0x65 0x6c 0x6c 0x6f. Going the other way, /w== decodes to the single byte ff.
Options
When encoding, URL-safe produces Base64URL for JWTs and URLs. When decoding to hex, choose Uppercase (6C vs 6c), add a 0x prefix for C, Java, or Python byte arrays, and pick the separator: spaces, none for a compact string such as a hash, or one byte per line. The decoder accepts padded, unpadded, wrapped, and URL-safe Base64 as well as data URIs.
Related tools
To see which text a hex string represents, use Hex to UTF-8. For bit-level views try Binary to Base64, and for Base32 secrets such as TOTP keys use Base32 Encode / Decode.
Frequently Asked Questions
How do I convert a SHA-256 hex digest to Base64?
Paste the 64-character hex digest as one continuous string. It is split into 32 bytes and encoded to a 44-character Base64 string. This is the format used by Subresource Integrity (integrity="sha256-..."), CSP hashes, and many API signature headers.
Which hex formats can I paste?
Space, comma, or newline separated bytes (48 65 6c), continuous strings (48656c), and prefixed bytes like 0x48, \x48, or %48. Upper and lower case letters are both fine. A continuous string must have an even number of digits.
Why does the hex output have twice as many characters as bytes, but Base64 fewer?
Hex uses 2 characters per byte (100% overhead), while Base64 uses 4 characters per 3 bytes (about 33% overhead). That's why hashes, keys, and binary IDs are often stored as Base64 when space matters and shown as hex when readability matters.