Hex to Base32 Converter
Hex to Base32 Converter. Paste your bytes into Hex Input and the Hex to Base32 Converter instantly encodes them into Base32 Output. Use the hex to base64 converter to turn hex-encoded data into the Base64 format expected by emails and data URIs.
Paste a hexadecimal string into this hex to base32 converter and you get back a Base32-encoded string that survives email, QR codes and voice dictation. Under the hood your hexadecimal input becomes raw binary data, which is regrouped into 5-bit chunks and mapped to a 32-character alphabet, so a value like B7E151 turns into W7QVC=== in one click.
How the Hex to Base32 Converter Turns Bytes into Letters
Hex and Base32 are two views of the same bytes. A hexadecimal digit carries 4 bits, so two digits describe one byte. Base32 carries 5 bits per character, which is why the converter has to dissolve your hex digits into one long run of bits and then slice that run again at a different width. Nothing about the value changes; only the grouping does.
Convert Hex to Base32 Step by Step
The conversion steps are the same for every input, short or long:
- Split the hex string into pairs and write each pair as 8 bits, giving the binary equivalent of every byte.
- Join all the bits into a single sequence, left to right, with no gaps.
- Cut that sequence into 5-bit groups, starting from the left.
- If the last group is short, pad it on the right with zero bits until it reaches five.
- Look each group up in the Base32 alphabet, where 0 is A, 25 is Z, 26 is 2 and 31 is 7.
- Append = characters until the output length is a multiple of eight.
Worked Example: B7E151 Becomes W7QVC===
Take the six hex digits B7E151. In binary that is 10110111 11100001 01010001, which is 24 bits. Regrouped into fives it reads 10110 11111 10000 10101 0001, and the last group is one bit short, so the converter adds a zero to make 00010. The five values are 22, 31, 16, 21 and 2.
| 5-bit group | Value | Base32 character |
|---|---|---|
| 10110 | 22 | W |
| 11111 | 31 | 7 |
| 10000 | 16 | Q |
| 10101 | 21 | V |
| 00010 (padded) | 2 | C |
Five characters is not a full block, so three = signs follow and the finished result is W7QVC===. Feed the same hex to the hexadecimal to base-32 routine in any library and you should see exactly that string.
The converter reads your hexadecimal text as bytes, not as a number, so nothing is trimmed from either end. The value B7E151 also equals 12050769 in decimal, but that figure never enters the Base32 result; only its binary bytes do. A hexadecimal string with a leading zero byte, such as 00B7E151, therefore produces a longer Base32 string than B7E151, because the extra zero byte is real binary content and the converter keeps it.
Base32 Alphabet, RFC 4648 and Padding Rules
The standard behind almost every implementation is RFC 4648. It defines a transfer encoding that turns arbitrary bytes into text from a fixed alphabet, and it is why two different tools agree on the same output for the same input. The simplest way to turn a duodecimal figure into hex is the base12 to hex converter, which handles the base conversion automatically.
The 32-Character Set: A-Z and 2-7
The base32 alphabet is the uppercase letters A-Z followed by the digits 2-7. The digits 0, 1, 8 and 9 are left out so that 0 and O, or 1 and I, can never be confused when someone reads a value aloud or copies it by hand. That restricted character set is also case-insensitive in practice: a decoder can accept lowercase input without any ambiguity, although the canonical output stays uppercase.
How Padding Fills the Last 40-Bit Block
Base32 works in blocks of 40-bit input, which is five bytes and exactly eight output characters. When your data does not fill the last block, padding with = completes it. The amount of padding depends only on how many bytes are left over.
| Input bytes | Hex digits | Data characters | Padding |
|---|---|---|---|
| 1 | 2 | 2 | 6 |
| 2 | 4 | 4 | 4 |
| 3 | 6 | 5 | 3 |
| 4 | 8 | 7 | 1 |
| 5 | 10 | 8 | 0 |
The data length follows one formula, where \(n\) is the number of bytes:
$$\text{data characters} = \left\lceil \frac{8 \times n}{5} \right\rceil$$Some protocols drop the padding altogether, so check what the receiving system expects before you strip or keep it.
Base32hex and Crockford Variants
Two other alphabets share the same 5-bit logic. Base32hex uses 0-9 followed by A-V, so its characters sort in the same order as the numbers they represent. Crockford Base32 removes the letters I, L, O and U to stay human-readable and adds an optional check symbol. The groups of bits stay identical; only the lookup table changes, so make sure the converter and the receiver agree on the variant. This converter outputs the RFC 4648 standard alphabet, so a receiver expecting another variant needs a matching decoder or a re-mapped alphabet.
Why Use an Online Tool for Hexadecimal to Base-32 Encoding
Whenever a hexadecimal dump from a log, a database column or a hardware token has to become text that a person can type, a converter saves real time. Doing the regrouping by hand is fine for three bytes and miserable for thirty. An online tool removes the bit-shifting errors, shows the step-by-step breakdown and lets you copy a clean result. Because the work is client-side, your value does not have to leave the browser.
TOTP Secret Keys and Two-Factor Authentication
The most common reason people convert is TOTP. Authenticator apps expect a Base32 secret, while many servers store the same secret keys as hex. A 20-byte key is 40 hex digits and becomes exactly 32 Base32 characters with no padding, ready to paste into an authentication app. The same step is needed when you migrate TOTP secrets between systems for 2-factor authentication.
QR Codes, API Keys and Email-Safe Text
Base32 shows up wherever a value has to be typed or scanned. A QR code for an authenticator enrolment embeds a Base32 secret, and many API keys use it because the output is email-safe and binary-safe: no punctuation, no symbols that a mail client might rewrite. That makes it a practical choice for data encoding in software development and cryptography workflows.
Base32 to Hex: Reverse Conversion and Decoding
You will often need the way back. The reverse conversion removes any padding, maps each character to its 5-bit value, joins the bits and regroups them into bytes. Any leftover bits that do not make a full byte are the zero fill added during encoding and are discarded. If you start from W7QVC===, the result after you decode it is B7E151 again.
Checking a Round Trip from Base32 to Hex
A good habit is to run base32 to hex on your result straight away. If the value you get back matches what you started with, the alphabet, case and padding settings were all consistent. Whenever a base32 to hex check fails, the usual causes are a mixed-up alphabet variant or a stray character in the pasted text.
Hex to Base32 for a 20-Byte Authenticator Secret
A sysadmin is retiring an old login portal and has to re-enrol a service account in an authenticator app. The portal's database stores the shared secret as 40 hex digits: 9C4E7A12D3B8F05E61A7C2D94B0E38F6A15D7C93. The app only accepts Base32, so the first job is to count what is there. Forty digits at 4 bits each is 160 bits, or 20 bytes, which matches the 160-bit secret length that RFC 4226 recommends for HMAC-SHA-1 one-time passwords (its floor is 128 bits).
They paste the string into the converter with padding left on. Twenty bytes is exactly four full 40-bit blocks, so the result is 32 characters and no = signs at all:
TRHHUEWTXDYF4YNHYLMUWDRY62QV27ET
The portal's old export screen shows only the first eight characters, so the sysadmin checks them against the eight characters the converter produced for the first 5 bytes: 9C4E7A12D3 becomes TRHHUEWT, and the two agree. Typing 32 characters in one run is error-prone, so they split the value into eight groups of four (TRHH UEWT XDYF 4YNH YLMU WDRY 62QV 27ET), which the app accepts once the spaces are dropped on entry.
Before deleting anything, they run the Base32 string back through the reverse direction and get all 40 hex digits unchanged. Only then do they enrol the account, read the first six-digit code from the app and compare it with the code the old portal generates for the same 30-second window. The codes match, so the old record can be deleted safely.
Hex vs Base32 vs Base64: Size and Readability
Each numeral system or encoding makes a different trade between length and friendliness, and the table below puts the same binary bytes into three of them. Base-16 is hexadecimal itself, with the longest text and the simplest mapping, since every pair of hexadecimal digits is exactly one byte, and a person can check it by eye against a hexadecimal dump or a decimal value. Base 64 is the most compact, but it is case-sensitive and uses symbols such as + and /. Base32 sits in between: longer than Base64, yet safe for case-insensitive systems.
| Encoding | Bits per character | 3-byte value | 20-byte key |
|---|---|---|---|
| Hexadecimal | 4 | B7E151 (6 characters) | 40 characters |
| Base32 | 5 | W7QVC=== (8 characters) | 32 characters |
| Base64 | 6 | t+FR (4 characters) | 28 characters |
If you are comparing against Base64, remember that Base32 is the longer encoding scheme because each character carries one bit fewer. Sibling tools cover other targets such as base 36, octal or decimal (the wider numbers conversion family), but only Base32 is produced here.
Convert Hex to Base32 in Python and JavaScript
If you would rather script the job, every major language has libraries for it. This hex to base32 converter tool follows the same logic as the snippets below, which matter for programming tasks like batch migrations.
Python Example
Python ships with the encoder in its standard library, so the whole conversion is two calls:
import base64
print(base64.b32encode(bytes.fromhex("B7E151")).decode()) # W7QVC===JavaScript Example
In JavaScript you can write the logic directly, which also shows the 5-bit regrouping clearly:
function hexToBase32(hex) {
const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
let bits = "";
for (const h of hex.match(/../g)) bits += parseInt(h, 16).toString(2).padStart(8, "0");
let out = "";
for (let i = 0; i < bits.length; i += 5)
out += A[parseInt(bits.slice(i, i + 5).padEnd(5, "0"), 2)];
while (out.length % 8) out += "=";
return out;
}Common Input Errors, Validation and Security
Most failed conversions come from the input rather than the maths, so a careful converter applies validation before it encodes anything.
Input Validation and Error Handling
Good error handling catches the usual mistakes before they produce a wrong string:
- An odd number of hexadecimal digits, which cannot form whole bytes of binary data.
- Characters outside 0-9 and A-F, including stray spaces or a pasted
0xprefix. - Text pasted when you meant to encode hex: with an input encoding such as UTF-8 or ASCII the same characters produce different bytes and therefore a different result.
- Mixing alphabets, for example reading a Base32hex value as standard Base32.
Encoding, Not Encryption
Base32 is encoding, not encryption. Anyone can reverse it without a key, so converting a secret does not protect it. Treat tokens and keys with the same security care before and after conversion, and for large batches expect performance to scale linearly with input length, since this converter handles each byte once.