Hex to Base64 Converter

Encode hexadecimal byte sequences as standard Base64 while preserving every byte, with a reverse mode for checking Base64 payloads as hex.

Last updated: August 2026 | By Workshelve Team

Whitespace and optional 0x prefixes are ignored; bytes must use two hex digits.

3q2+7wAB

What Hex-to-Base64 Encoding Is For

Hexadecimal byte strings are convenient for logs, packet dumps, signatures, and low-level debugging, but many APIs and text formats expect binary values to be carried as Base64 instead. Hex → Base64 turns the byte sequence into a compact ASCII-safe representation without changing the bytes themselves.

The encoder reads each two-digit hex pair as one byte, preserves the original order and leading zero bytes, then encodes the complete byte stream as standard Base64. Spaces and line breaks are allowed for readability, and an optional0x prefix may appear at the start of individual byte values.

This is byte encoding, not numeric conversion. For example, the hex bytes00 10 are treated as two bytes in that order; they are not first collapsed into the number 16.

How Hex Bytes Become Base64

Preserve the byte stream, then encode it

1. Validate that the input contains complete two-digit hex bytes.
2. Remove presentation-only whitespace and valid 0x byte prefixes.
3. Reconstruct the byte stream in exactly the order entered.
4. Base64-encode those bytes, adding = padding only when the final group needs it.
One byte → two padding characters
ff
/w==
Two bytes → one padding character
ff ee
/+4=
Three bytes → no padding
ff ee dd
/+7d
Six-byte binary sequence
de ad be ef 00 01
3q2+7wAB

Base64 processes the byte stream in groups of three bytes. A final group of one or two bytes is represented with = padding so the encoded text still ends on a four-character Base64 group.

Worked Example: Encoding a Hex Byte Sequence

Encode DE AD BE EF 00 01 as Base64:

Input:
DE AD BE EF 00 01
Group:
Six bytes form two complete three-byte Base64 groups: DE AD BE and EF 00 01.
Encode:
DE AD BE → 3q2+    EF 00 01 → 7wAB
Result:
3q2+7wAB

No padding is required because the input length is exactly six bytes, which divides evenly into three-byte groups.

Hex to Base64 FAQ

Why encode a hex byte string as Base64?

Base64 is commonly used when binary bytes must travel through JSON, XML, form fields, configuration files, or other text-only channels. It represents the same bytes using a restricted text alphabet.

Are 0x prefixes included in the Base64 data?

No. A prefix such as 0xDE is notation that marks DE as a hexadecimal byte. The prefix is removed before the byte stream is encoded.

Are leading 00 bytes preserved?

Yes. Every complete two-digit pair is treated as a byte, including 00. Leading zero bytes remain part of the byte stream and therefore affect the Base64 output.

Does the converter change byte order?

No. Bytes are encoded in the order entered. The tool does not apply little-endian or big-endian reinterpretation because it is not converting a multi-byte number.

Why does some Base64 output end with = or ==?

Padding depends on the number of input bytes. One leftover byte produces two padding characters, two leftover bytes produce one, and a multiple of three needs none.

Can I encode an odd number of hex digits?

No. Each byte requires exactly two hex digits. A value such as ABC is ambiguous as a byte stream, so the converter asks you to provide complete byte pairs.

Is the result standard Base64 or Base64URL?

The result is standard Base64, which may contain + and /. Base64URL uses - and _ instead and is a separate variant.

Can I paste a spaced or line-wrapped hex dump?

Yes. Whitespace is ignored. You can also use optional 0x prefixes at byte boundaries, such as 0xDE 0xAD 0xBE 0xEF.

Related Tools