Free exact browser converter
Hex to BCD Converter
Convert a hexadecimal integer to 8421 BCD online. Get grouped bits, compact BCD, or unsigned packed BCD hex with strict validation and exact precision.
Interactive tool
Convert Hex to BCD
Ready
Choose a clear output representation.
Detailed conversion guide
How to Convert Hex to BCD
Parse the input as a hexadecimal integer, convert its value to decimal digits, then encode each digit as a four-bit 8421 BCD group. Hex 3B is decimal 59 and becomes 0101 1001.
The packed BCD hex option writes those decimal digits as unsigned BCD nibbles: hex 3B becomes packed BCD 0x59. It does not interpret the input as BCD. Entering hex 59 converts decimal 89 and produces BCD 1000 1001.
| Input | Output | Meaning |
|---|---|---|
0 | 0000 | zero |
A | 0001 0000 | decimal 10 |
3B | 0101 1001 | decimal 59 |
FF | 0010 0101 0101 | decimal 255 |
Hex Integer to Four-Bit BCD Digits
The algorithm validates the representation before exact integer conversion, so malformed input never produces a plausible partial answer.
const hex = input.trim().replace(/^0x/i, "");
if (!/^[0-9a-f]+$/i.test(hex)) throw Error("Invalid hex");
const digits = BigInt("0x" + hex).toString(10);
const bcd = [...digits].map(d => (+d).toString(2).padStart(4,"0"));
const result = bcd.join(" ");Integer Hex versus Packed BCD Hex
Digits A–F are valid in the hexadecimal integer input. BCD output digits are restricted to 0000–1001. This converter does not decode an existing packed BCD payload or infer a sign nibble.
Fractions, negative values, and repeated 0x prefixes are rejected. Numeric leading zeros are removed before BCD encoding. Packed output omits byte padding and a sign nibble; add byte padding only if your protocol requires it.
Related converters
Continue with exact representation converters
Choose the converter for the input and output formats you are working with.