Real-time · Client-Side · Zero Uploads

Hex to Base64 Converter

Paste any hexadecimal string and instantly convert it to Base64. Supports raw hex, spaced hex, colon-separated, and 0x-prefixed formats. Reverse conversion and byte inspector included.

Input format:
Output:
Hexadecimal Input 0 chars
Base64 Output 0 chars
5
Input Formats
2
Output Modes
0ms
Server Latency
100%
Private & Secure

Convert Hex to Base64 in Three Steps

No sign-up, no server uploads. Paste, convert, and copy in seconds.

1

Paste Your Hex String

Paste raw hex (48656c6c6f), spaced hex (48 65 6c), colon-separated (48:65:6c), or 0x-prefixed hex. Upper and lowercase are both accepted. The tool auto-detects the format.

2

Instant Conversion

Each hex pair is parsed into a byte value (0255). The resulting byte array is then Base64-encoded using the standard RFC 4648 alphabet. Conversion happens in real-time as you type.

3

Copy or Download

Copy the Base64 output to clipboard with one click, or download it as a .txt file. Switch to Base64URL mode for URL-safe output, or use the byte inspector to analyse your hex data.

Everything You Need for Hex & Base64

A complete conversion toolkit with format flexibility, reverse conversion, and byte-level inspection.

5 Hex Input Formats

Auto-detects raw hex, space-separated, colon-separated, and 0x-prefixed hex. Handles uppercase, lowercase, and mixed case. Strips whitespace and delimiters automatically before conversion.

🔄

Base64URL Mode

Switch output to Base64URL (RFC 4648 §5) which replaces + with -, / with _, and omits padding. Essential for JWT tokens, URL query parameters, and filename-safe encodings.

Reverse: Base64 → Hex

Decode any Base64 or Base64URL string back to a hex representation. Choose the output hex format: lowercase spaced, uppercase, raw, colon-separated, or 0x-prefixed.

🔎

Byte Inspector

Paste any hex string to see a visual grid of every byte showing its hex value, decimal equivalent, and ASCII character (where printable). Useful for inspecting packet data, hash outputs, and binary streams.

📊

Conversion Stats

After every conversion, see the byte count, input hex character count, output Base64 character count, and the Base64 overhead percentage. Useful for understanding encoding size costs.

🔒

100% Private

All conversion uses pure JavaScript running in your browser tab. Nothing is sent to any server. Safe for cryptographic keys, hash values, API tokens, and any sensitive binary data represented as hex.

Hex, Binary & Base64 Examples

How hexadecimal bytes map through binary to Base64 characters. Base64 groups 3 bytes (6 hex pairs) into 4 characters.

DescriptionHex StringBytes (Decimal)BinaryBase64 Output
"Hello"48 65 6c 6c 6f72 101 108 108 11101001000 01100101…SGVsbG8=
"Hello World"48 65 6c 6c 6f 20 57 6f 72 6c 6472 101 108… 10001001000…SGVsbG8gV29ybGQ=
Zero bytes00 00 000 0 000000000 00000000 00000000AAAA
Max bytesFF FF FF255 255 25511111111 11111111 11111111////
SHA-256 prefixe3 b0 c4 42 98 fc227 176 196…11100011…47DEQpj8HBSa+/TI
Single byte416501000001QQ==
Two bytes41 4265 6601000001 01000010QUI=
Three bytes41 42 4365 66 6701000001 01000010 01000011QUJD

When You Need Hex as Base64

Converting hex to Base64 comes up frequently across cryptography, networking, and API development.

01

Cryptographic Key & Hash Encoding

Cryptographic libraries often output keys, IVs, salts, and hashes as hex strings. Many APIs and storage formats (JWT, JWK, PEM headers) expect these values as Base64. Convert your openssl or hashlib hex output here in one step.

02

Network Packet & Protocol Debugging

Packet capture tools like Wireshark export payloads as hex dumps. Converting those hex bytes to Base64 lets you paste them directly into API test tools (Postman, Insomnia) that expect Base64-encoded binary payloads in JSON request bodies.

03

JWT & Token Construction

JSON Web Tokens use Base64URL encoding for their header, payload, and signature. When building or debugging JWTs manually, you often need to convert a raw hex signature (from an HMAC or ECDSA operation) to Base64URL. The Base64URL output mode handles this directly.

04

Database BLOB & Binary Field Handling

Databases like PostgreSQL and MySQL often display binary columns as hex strings in query output. Convert these hex values to Base64 to embed them in JSON API responses, GraphQL fields, or to store them in Base64-compatible text columns.

05

TLS Certificate & Key Inspection

X.509 certificate fingerprints are commonly shown as colon-separated hex (AA:BB:CC:…). Paste the colon format directly into this tool to convert the fingerprint to Base64 for use in HTTP Public Key Pinning (HPKP) headers or certificate comparison scripts.

06

Firmware & Embedded Systems Data

Firmware images and memory dumps are routinely exported as hex files or hex strings. Converting sections to Base64 makes them easier to embed in JSON configuration payloads, OTA update APIs, and device provisioning scripts that transport binary data over text-based protocols.

Hex to Base64 Conversion Explained

Hexadecimal is a base-16 number system where each digit represents 4 bits. Two hex digits form one byte (8 bits), ranging from 00 (0) to FF (255). So a hex string is simply a text representation of raw binary data.

Base64 encodes binary data by taking 3 bytes (24 bits) at a time and splitting them into four 6-bit groups. Each 6-bit group maps to one of 64 printable ASCII characters using the standard Base64 alphabet (AZ, az, 09, +, /). If the byte count isn't divisible by 3, padding characters (=) are appended.

The conversion pipeline is: strip hex delimiters → parse pairs into byte values → build a Uint8Array → encode with btoa() or the equivalent Base64URL encoder. The result is always approximately 33% larger than the original byte count.

// Hex string → Base64 (JavaScript)
 
function hexToBase64(hex) {
  // Strip spaces, colons, 0x prefixes
  const clean = hex
    .replace(/0x/gi, '')
    .replace(/[^0-9a-f]/gi, '');
 
  // Parse pairs into bytes
  const bytes = clean
    .match(/.{2}/g)
    .map(h => parseInt(h, 16));
 
  // Encode to Base64
  return btoa(
    String.fromCharCode(...bytes)
  );
}

Frequently Asked Questions

Everything you need to know about converting hex to Base64.

Both are text representations of binary data. Hexadecimal uses 2 characters per byte from a 16-character alphabet (09, af), so it expands binary data to exactly twice the original size. Base64 uses 4 characters per 3 bytes from a 64-character alphabet, expanding data by about 33%. Base64 is more compact but less human-readable than hex. Hex is preferred in debugging and security contexts; Base64 is preferred in data transport and storage.
Yes. Since each byte is represented by exactly 2 hex digits, a valid hex string must have an even number of characters after stripping delimiters. If you paste an odd-length hex string, the tool will flag it as an error. Some tools zero-pad or truncate odd-length input this tool reports the error so you can verify your source data is correct.
Base64URL (defined in RFC 4648 §5) is a variant that replaces + with - and / with _, and omits the trailing = padding. This makes the output safe for use in URLs, filenames, and HTTP headers without percent-encoding. Use Base64URL whenever your Base64 value will appear in a JWT, a URL query parameter, a cookie, or any context where +, /, or = would need to be escaped.
Base64 encodes data in 3-byte blocks. When the total byte count is not divisible by 3, the final block is padded with zero bits and one or two = characters are appended to reach the required 4-character block length. One = means the original data had 2 bytes in the last group; two == means 1 byte. This padding allows decoders to determine the exact original byte count.
Yes. Select Colon-separated from the input format dropdown, or leave it on Auto-detect. The tool strips all colons before parsing, so a TLS certificate fingerprint like AA:BB:CC:DD:EE:FF is handled automatically. The same applies to colon-separated MAC addresses and other colon-delimited hex formats.
Paste the 64-character hex hash string into the input field. The tool will parse it as 32 bytes and output a 44-character Base64 string (43 characters + one = padding). This is a common operation when computing Content-Security-Policy script hashes, comparing certificate fingerprints, or preparing HTTP Public Key Pinning header values.
Yes, and it is done entirely in your browser with no server contact. This tool is safe for sensitive values like private keys, HMAC secrets, and AES key material. The conversion uses only JavaScript's built-in parseInt and btoa() functions no third-party libraries, no analytics, no network requests beyond the initial page load.
The Byte Inspector tab parses your hex string and displays each byte as a visual card showing: the hex pair (e.g. 48), the decimal value (e.g. 72), and the ASCII character if the byte falls in the printable range (32126). This makes it easy to spot embedded strings, null bytes, control characters, and high-byte values within a hex payload.