Convert Hex to BCD
Convert hex to Binary Coded Decimal - packed, unpacked, or COMP-3 with sign nibble. BigInt-safe for 64+ digit inputs. Free, offline, 100% client-side.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Convert a hexadecimal value into Binary Coded Decimal. Choose between packed (4 bits per digit), unpacked (8 bits per digit), or COMP-3 (mainframe/COBOL signed, with C/D sign nibble). BigInt math for arbitrarily long inputs.
How to Use Convert Hex to BCD
- Paste your hex values, one per line. Leading
0x/0Xprefix is optional; spaces and underscores as separators (DE_AD_BE_EF) are stripped automatically. Case doesn't matter. - Pick the BCD format. Packed gives you the most compact output (4 bits per digit). Unpacked uses 8 bits per digit (high nibble zeroed) - this matches EBCDIC / zoned-decimal on mainframes. COMP-3 is the IBM signed packed format used in COBOL (appends a C or D sign nibble).
- For COMP-3 specifically, prefix your hex with
-if the value is negative (e.g.-0x1A). Packed and Unpacked modes reject negatives - use COMP-3 for signed. - Toggle nibble grouping to get
0010 0101instead of00100101. This only affects display; the underlying bits are identical. - Toggle the
0bprefix if you need Python/ES6-style binary literals. - Press Convert (or Ctrl+Enter / Cmd+Enter). Auto-convert runs 200 ms after each keystroke so the output updates as you type.
- Read the stats line and breakdown: stats show total lines, successes, errors, max decimal-digit count, and the largest value. The breakdown shows each row's
hex → decimal → BCDchain with bit count.
Frequently Asked Questions
What’s the difference between packed and unpacked BCD?
Packed BCD stores two decimal digits per byte – each digit occupies exactly 4 bits. So decimal 25 becomes one byte 0010 0101. Unpacked BCD uses a full byte per digit, with the high nibble zeroed – decimal 25 becomes two bytes 00000010 00000101. Packed is twice as dense; unpacked is easier for mainframe zoned-decimal I/O.
What is COMP-3 and when would I use it?
COMP-3 (computational-3) is IBM’s signed packed-BCD format, standard in COBOL on z/OS mainframes. Each decimal digit is 4 bits, and the final nibble holds a sign: C (binary 1100) for positive or D (1101) for negative. Decimal 25 becomes 0010 0101 1100 (12 bits), and −25 becomes 0010 0101 1101. Used to transfer signed decimals between modern systems and mainframes.
Why does this use BigInt instead of regular numbers?
Because 16+ digit hex values exceed JavaScript’s Number.MAX_SAFE_INTEGER (253 − 1 ≈ 9 × 1015). Using regular Number, the hex FFFFFFFFFFFFFFFF (64-bit max) would silently lose precision. BigInt handles any width exactly, so 20-digit or 40-digit hex values round-trip perfectly to BCD.
Which hex input formats are accepted?
All common ones. Bare digits (FF), C-style prefix (0xFF or 0XFF), with spaces (DE AD BE EF), with underscores (DE_AD_BE_EF), and any mix. Case-insensitive – aB and Ab both work. Leading - or + sign is accepted (but non-COMP-3 formats reject negatives).
What happens if one line has a bad character?
Only that line fails. The tool processes lines independently, so a stray Z in one row becomes a single red entry in the breakdown (“Line 3: invalid hex character ‘Z’ at position 2”) while every other line still converts. The stats row shows exactly how many succeeded versus failed.
Why would I want BCD at all in 2026?
Four real-world reasons. One: mainframe integration – COBOL databases still store financial amounts as COMP-3. Two: avoiding float rounding in money math – BCD represents decimal digits exactly, unlike binary floating-point. Three: 7-segment display drivers expect packed BCD. Four: some legacy industrial PLCs and calculator ASICs still emit BCD over their I/O pins.
Why are negatives rejected in packed/unpacked mode?
Because neither format has a built-in way to represent sign. Packed and unpacked BCD store digit nibbles only – there’s no sign bit to set. Historical systems used accompanying sign bytes or agreed-upon conventions, but those aren’t portable. COMP-3 was invented specifically to encode sign in the same stream, so the tool restricts negative input to that mode.
How many bits will my output have?
For packed BCD, it’s 4 × (number of decimal digits in your value). For unpacked, 8 × decimal digits. For COMP-3, 4 × digits + 4 bits for the sign nibble, padded up to the next byte boundary. Example: decimal 12,345 → 5 digits → packed 20 bits, unpacked 40 bits, COMP-3 24 bits. The stats row shows the bit count per row.
Is my input uploaded anywhere?
No. All arithmetic runs in your browser’s JavaScript engine – no network requests fire during conversion, and no server stores or logs your hex values. The tool keeps working after you disconnect from the internet. You can verify with your browser’s Network tab.
Can I round-trip BCD back to hex?
Yes. Packed and unpacked BCD are bijective with their decimal values, and any decimal can be written back to hex exactly. Use a BCD-to-hex converter (or decode the BCD to decimal mentally, then convert decimal to hex) and you’ll get the original hex back. COMP-3 also round-trips losslessly, including sign.
Related Tools
BCD to Hex Converter →
Convert packed BCD to hexadecimal - decimal-value or nibble mode, BigInt precision, COMP-3 sign.…
Add Hex Numbers →
Add Hex Numbers instantly. Free, offline, client-side tool that outputs results in both hex…
ASCII to Hex Converter →
Convert ASCII to Hex - code points or UTF-8 bytes, space/comma/0x-prefixed, uppercase or lowercase.…
Base32 to Hex Converter →
Base32 to Hex Converter - pick separator, case, and prefix. Free, client-side, instant, offline,…
Base58 to Hex Converter →
Decode Bitcoin, Ripple, or Flickr Base58 strings to hex - with separator, case, and…
Base64 to Hex Decoder →
Decode Base64 to hex bytes - URL-safe variant, separator options, uppercase toggle, UTF-8 aware.…
Convert Decimal to Hex →
Convert decimal numbers to hexadecimal instantly, individually or in bulk. Free, client-side converter with…
Convert Gray Code to Hex →
Decode Gray code (reflected binary) to hex, decimal, or binary. Accepts binary or hex-packed…
Convert Hex to ASCII →
Decode hexadecimal bytes to ASCII text. Auto-detect separators, handle non-printable bytes four ways, batch…
Convert Hex to Binary →
Convert hex to binary with nibble-accurate bit widths. 5 grouping modes, 0b prefix toggle,…
Convert Hex to Decimal →
Convert hex to decimal with BigInt precision. Explicit bit-width two's complement for signed values,…
Convert Hex to Gray Code →
Convert hex to Gray code (reflected binary) with BigInt precision. Handles 32+ bit values…