Hex to Base64 Converter
Convert hexadecimal bytes to a Base64 string instantly - accepts spaced, comma-separated, 0x-prefixed, or continuous hex.
5 bytes encoded to 8 Base64 characters
How to Convert Hex to Base64
Hex and Base64 are both ways to write the same underlying bytes:
- Group your hex into pairs - each pair is one byte (48 → 0x48)
- Take the bytes three at a time (24 bits)
- Split those 24 bits into four 6-bit groups
- Map each 6-bit value (0-63) to its Base64 character; pad with = when fewer than three bytes remain
Example: Encode 48 65 6C 6C 6F ("Hello"):
- Bytes: 0x48 0x65 0x6C | 0x6C 0x6F (two groups: three bytes, then two)
- First group 010010 000110 010101 101100 → S G V s
- Second group pads one byte: bG8=
- Result: SGVsbG8=
Code Examples
const hex = "48656c6c6f";
const bytes = new Uint8Array(hex.match(/.{2}/g).map((h) => parseInt(h, 16)));
let binary = "";
for (const b of bytes) binary += String.fromCharCode(b);
btoa(binary); // "SGVsbG8="Frequently Asked Questions
How do I convert hex to Base64?
Each pair of hex digits becomes one byte; every three bytes are regrouped into four Base64 characters, padded with = when the byte count is not a multiple of three. For example, 48 65 6C 6C 6F becomes SGVsbG8=.
What hex input formats are accepted?
Spaces (48 65), commas (48,65), 0x prefixes (0x48 0x65), and one continuous string (4865) all work. Whitespace and separators are ignored automatically.
Is this standard Base64 or URL-safe Base64?
Standard RFC 4648 Base64 with + and / and = padding - the form used by email (MIME), data URIs, JWT segments after translating, and most APIs. If you need the URL-safe variant, replace / with _ and + with -, and drop the padding.
Does my data leave my device?
No. The conversion runs in your browser with plain JavaScript - nothing you paste is uploaded, logged, or stored.
Related Tools
Base64 to Hex Converter
Decode a Base64 string into its raw bytes as hexadecimal - missing padding is tolerated, whitespace is ignored.
Hex to Text Converter
Convert hexadecimal bytes into readable ASCII or UTF-8 text instantly.
Hex Dump Viewer
Paste text, hex or base64 and read it back as a hexdump with byte offsets, hex columns and an ASCII gutter.
Bytes to Int Converter
Convert hex bytes to signed or unsigned integers using big-endian or little-endian byte order.
This tool runs entirely in your browser - nothing you enter is uploaded or stored.