BCD Converter — Binary-Coded Decimal (8421 & Excess-3)
Convert a decimal number to and from Binary-Coded Decimal (BCD). See each digit as its 4-bit 8421 code and Excess-3 (XS-3) code, get the packed hex value, and decode a packed BCD value back to decimal — with invalid nibbles flagged. Live, in your browser.
How to Use
- Type a decimal number in the “Decimal” box to encode it — the 8421 and Excess-3 codes update instantly.
- Read the per-digit table to see how each decimal digit maps to its 4-bit code.
- Copy the spaced bit groups or the packed hex value with the Copy buttons.
- To go the other way, paste a BCD value (packed hex like <code>0x1234</code> or grouped bits) into the “Decode BCD” box — invalid nibbles A–F are flagged.
What Binary-Coded Decimal actually is
Binary-Coded Decimal (BCD) is a way of storing numbers that keeps the decimal digits intact: instead of converting the whole number to pure binary, each decimal digit 0–9 gets its own group of four bits, called a nibble. The number 1234 becomes 0001 0010 0011 0100 — one nibble per digit — whereas pure binary would mash it into 10011010010. Because a nibble can hold sixteen values but a decimal digit only needs ten, BCD “wastes” the six patterns 1010–1111 (hex A–F); those never appear in valid BCD. The pay-off is that the number stays human-readable at the digit level, which is exactly what you want for 7-segment displays, digital clocks, electricity meters and money math where rounding pure-binary fractions would be a nuisance.
8421, Excess-3 and packed BCD
The default code shown here is 8421 BCD — the name comes from the place values of the four bits (8, 4, 2, 1), so each digit is simply its plain 4-bit binary value: 5 → 0101, 9 → 1001. Excess-3 (XS-3) adds 3 to the digit before encoding, so 5 → 8 → 1000 and 9 → 12 → 1100. That offset makes XS-3 self-complementing: flipping every bit of a digit gives its 9’s complement, which simplified subtraction in early calculators. Packed BCD squeezes two digits into one byte, one per nibble; the lovely side-effect is that the byte’s hexadecimal reading is the decimal digits — 1234 packs to the bytes 0x12 0x34, i.e. the hex value 0x1234. Decoding reverses the process: split the value into nibbles and read each as a digit, rejecting any nibble outside 0–9.
Quick reference
About the BCD Converter — Binary-Coded Decimal (8421 & Excess-3)
Need a hand with everyday tasks? The BCD Converter — Binary-Coded Decimal (8421 & Excess-3) does the work for you — free, and right here in your browser. Convert a decimal number to and from Binary-Coded Decimal (BCD). See each digit as its 4-bit 8421 code and Excess-3 (XS-3) code, get the packed hex value, and decode a packed BCD value back to decimal — with invalid nibbles flagged. Live, in your browser.
How it works
Enter a number and choose your units — the converted value shows instantly. Everything runs locally, so nothing you type leaves your device. Double-check the direction of the conversion and you are set.
Want the deeper story? The Knowledge Base explains the ideas behind the tools in more detail.
Frequently Asked Questions
What is Binary-Coded Decimal (BCD)?
BCD stores each decimal digit (0–9) in its own group of four bits (a nibble) using the digit’s plain binary value. So 1234 becomes 0001 0010 0011 0100 — four nibbles, one per digit — rather than the pure-binary 10011010010. It keeps the decimal structure visible, which is handy for displays, meters and price arithmetic.
What is the difference between 8421 BCD and Excess-3?
8421 (“natural” or “true” BCD) writes each digit as its straight 4-bit binary value, so 5 is 0101. Excess-3 (XS-3) adds 3 to the digit first, so 5 becomes 8 → 1000. XS-3 is a self-complementing code (the 9’s complement of a digit is its bitwise complement), which simplifies subtraction in some older hardware.
What is packed BCD and why does 1234 read as hex 0x1234?
Packed BCD stores two decimal digits in one byte — one digit per nibble. Because each nibble holds 0–9, the hex reading of the bytes is literally the decimal digits: 1234 packs to the bytes 0x12 0x34, i.e. 0x1234. That neat coincidence is exactly why BCD is convenient.
Why are nibbles A–F invalid in BCD?
A valid BCD nibble only encodes 0–9 (0000–1001). The patterns 1010–1111 (hex A–F) never represent a decimal digit, so if you decode a value like 0x1A the A is illegal — this tool flags it as “not valid BCD”.
Is anything uploaded?
No. Every conversion runs locally in your browser with JavaScript; nothing is sent to a server.
How do I use the BCD Converter — Binary-Coded Decimal (8421 & Excess-3)?
Simply type or paste your value and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Is it free? Does it work without internet?
Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.
Where does my data go?
Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.
Common Use Cases
Digital logic & electronics
Drive 7-segment displays, BCD counters (7490) and decoder ICs (7447) that expect one decimal digit per nibble.
Embedded & RTC chips
Read or write real-time-clock and calendar registers (DS1307 and friends) that store time as packed BCD.
Learning number codes
See how 8421 and Excess-3 differ digit by digit, and why XS-3 is self-complementing.
Decoding data dumps
Turn a packed-BCD hex field from a protocol or memory dump back into the decimal number it represents.
Last updated: