Skip to content
Hex Calculator

Hex to Base64 Converter

Encode hex bytes as RFC 4648 Base64 — the byte encoding behind data URIs, JWTs, and email attachments, not a positional numeral system.

Base64 result
SGVsbG8=

How Hex to Base64 Encoding Works

Treat the hex input as bytes (every 2 hex digits = 1 byte). Group the bytes in sets of 3 (24 bits at a time), split each group into four 6-bit chunks, and map each chunk to one of Base64's 64 characters. Pad the final group with = if the byte count isn't a multiple of 3.

Hex to Base64 Example, Step by Step

"Hello" in hex = SGVsbG8=

48656C6C6F (hex) = SGVsbG8= (Base64)

Bytes: 48 65 6C 6C 6F (5 bytes)

Group 1: 48 65 6C -> 3 bytes -> 4 chars, no padding
Group 2: 6C 6F (only 2 bytes left) -> 3 chars + 1 padding =
StepDescriptionResult
Group into 3-byte chunks48 65 6C, then 6C 6F (short by 1 byte)2 groups
Encode first group48 65 6C -> 4 Base64 charactersSGVs
Encode second (short) group6C 6F -> 3 characters + 1 padding =bG8=
Combinejoin both groupsSGVsbG8=

5 bytes doesn't divide evenly by 3, so the final group is short one byte — that's why the output ends in a single = rather than no padding at all.

Common Mistakes With Hex to Base64

  • Confusing this with a positional base conversion — RFC 4648 Base64 encodes bytes, not a single number.
  • Forgetting an odd hex digit count needs a leading zero to complete the final byte.
  • Using standard Base64 output somewhere that requires the URL-safe variant (- and _ instead of + and /).

Frequently Asked Questions

Is this a base conversion like hex to base36?

No — this is a common point of confusion. Base36 represents one number compactly. Base64 here is RFC 4648's byte encoding, which turns arbitrary binary data into safe ASCII text — it doesn't represent the hex value as a single number at all.

How does RFC 4648 Base64 encoding work?

It groups input bytes into sets of 3 (24 bits), splits each group into four 6-bit chunks, and maps each chunk to one of 64 characters (A-Z, a-z, 0-9, +, /). If the input doesn't divide evenly into groups of 3, the output is padded with = characters.

Where is Base64 actually used?

Embedding images or fonts directly in CSS/HTML as data URIs, encoding the header and payload of JWTs, and attaching binary files to email — anywhere binary data needs to travel safely through text-only systems.

How does hex input map to bytes here?

Every 2 hex digits is one byte. An odd number of hex digits gets a leading zero added to complete the final byte before encoding.

Why does the output sometimes end with = or == ?

Base64 always produces output in multiples of 4 characters — padding fills out the last group when the byte count isn't a multiple of 3. One leftover byte gets ==, two leftover bytes get a single =.

Is Base64 the same as URL-safe Base64?

Not quite — standard Base64 uses + and /, which can conflict with URL syntax. URL-safe variants replace those with - and _ instead. This tool produces standard Base64.