Convert Hex to Base64
Paste hex in almost any format — spaces, newlines or 0x prefixes are cleaned automatically — and get the Base64 instantly, in your browser.
ⓘ Nothing to convert yet
Nothing to convert yet — paste your data or drop a file to begin.
Inspection Report
- Detected Type
- —
- MIME Type
- —
- Encoding
- —
- Input Length
- —
- Decoded Size
- —
- Padding Status
- —
- Data URI
- —
- File Signature
- —
- Preview Availability
- —
How to convert Hex to Base64
To convert hex to Base64, paste the hexadecimal string into the tool above. It accepts compact hex, space- or newline-separated bytes, and 0x-prefixed values, cleans the input automatically, and shows the exact byte count plus the Base64 result. Everything is converted locally in your browser — nothing is sent anywhere.
How to Use
- Paste your hex into the input box. 89504e47, 89 50 4e 47 and 0x89 0x50 0x4e 0x47 are all understood.
- Spaces, newlines and 0x prefixes are removed automatically; anything else invalid is flagged with its exact position.
- Check the byte count — each pair of hex digits is one byte.
- Copy the Base64 result, or the normalized hex if you need a clean version of your input.
- To decode Base64 back to hex, use the Base64 to Hex tool.
Real Example
Paste 48 65 6c 6c 6f and the tool reports 5 bytes and produces SGVsbG8= — the Base64 for the ASCII text "Hello". Paste the eight bytes 89 50 4e 47 0d 0a 1a 0a (with or without the spaces) and you get iVBORw0KGgo=, the famous opening of every Base64-encoded PNG. The normalized hex output shows your cleaned input, so you can verify exactly what was converted.
Code Snippets
// Hex (any spacing / 0x prefixes) to Base64 (browser)
const clean = hex.replace(/0x/gi, '').replace(/[^0-9a-f]/gi, '');
const bytes = new Uint8Array(clean.match(/../g).map(h => parseInt(h, 16)));
let binary = '';
bytes.forEach(b => (binary += String.fromCharCode(b)));
const base64 = btoa(binary);How Hex to Base64 Works
Hex shows up in the wild in many shapes: hex editors space-separate bytes, C code prefixes them with 0x, dumps add newlines every 16 bytes. This tool strips all of that before conversion and tells you exactly what it removed. What remains must be an even number of hex digits — two per byte — and the byte count display lets you sanity-check the length before trusting the output. The conversion itself is a direct byte re-encoding, so the Base64 always represents precisely the bytes your hex described.
Common Use Cases
- Turning a hex dump from a debugger or protocol analyzer into Base64 for transport.
- Preparing binary keys or hashes for systems that expect Base64 input.
- Converting byte sequences from documentation into a format APIs accept.
- Cleaning up inconsistently formatted hex before using it in code.