TOP

Free exact browser converter

Hex to Base64 Converter

Convert hex bytes to Base64 online. Preserve leading zero bytes, validate complete byte pairs, and choose padded Base64 or unpadded Base64url.

No signupRuns locally in your browser

Interactive tool

Convert Hex to Base64

Ready

Output format

Choose a clear output representation.

Detailed conversion guide

How to Convert Hex to Base64

Validate complete two-digit hex byte pairs, read each pair as a byte from 0 to 255, and encode those bytes in Base64. Hex 41 00 FF becomes QQD/. No intermediate text decoding occurs.

Encoding the literal text "41 00 FF" would produce a different result. This tool preserves byte order and zero bytes. Standard Base64 uses +, /, and = padding; Base64url uses - and _ and omits trailing = here.

InputOutputMeaning
00AA==one zero byte
FF/w==one byte 255
41 00 FFQQD/three raw bytes
48656C6C6FSGVsbG8=UTF-8 bytes of Hello

Encode Raw Hex Bytes in the Browser

The algorithm validates the byte representation before conversion. Invalid input clears the result and shows a warning.

const hex = input.trim().replace(/^0x/i, "").replace(/\s+/g, "");
if (!/^(?:[0-9a-f]{2})+$/i.test(hex)) throw Error("Invalid hex bytes");
const raw = hex.match(/.{2}/g).map(h => String.fromCharCode(parseInt(h,16))).join("");
const base64 = btoa(raw);

Byte Pairs, Padding, and Zero Bytes

A single hex digit such as F is rejected because a byte requires two digits; use 0F. Whitespace may group or wrap bytes. One optional 0x prefix applies to the entire input, so 0x41 0x42 is invalid.

00 FF and FF describe different byte sequences and produce AP8= and /w==. This converter does not parse data URLs, infer a character encoding, or perform integer conversion. Base64 is reversible encoding, not encryption.

Related converters

Choose a converter for the formats you are working with.

Advertisement

Sponsored link