Binary to BCD converter
Turn a binary number into the 8421 BCD pattern a multi-digit display needs: 101010 is 42, which becomes the groups 0100 and 0010. Each decimal digit gets its own four-bit group for seven-segment drivers and BCD counters. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Binary
- 101010
- Binary bits
- 6
- Decimal
- 42
- Decimal string
- 42
- Bcd
- 01000010
This binary to BCD converter takes a pure binary (base-2) integer as a string of zeros and ones, interprets its magnitude in decimal, then packs every decimal digit into a four-bit 8421 binary-coded decimal nibble—the same encoding seven-segment display drivers, BCD counters, and many industrial panels still use. Unlike a pure binary-to-decimal tool that only prints a base-ten number, or a decimal-to-BCD tool that starts from digits you already typed in base ten, this page answers the hardware-facing question: given a binary value from a register, counter, or lab problem, what BCD bit pattern should feed a multi-digit display? The engine is fully deterministic: it walks bits left to right, builds a safe non-negative integer, emits one nibble per digit with weights eight, four, two, and one, never calls the network, never samples randomness, and never depends on the clock.
What binary to BCD means and what you get
Binary-coded decimal in the natural 8421 form used here assigns every decimal digit from zero through nine a four-bit pattern whose bit weights are eight, four, two, and one from left to right. Digit zero is zero-zero-zero-zero, one is zero-zero-zero-one, five is zero-one-zero-one, and nine is one-zero-zero-one. Multi-digit values simply concatenate those nibbles in the same order as the decimal digits of the magnitude.
The critical first step on this page is different from a decimal BCD encoder: your input is a pure binary bit string. The calculator interprets that string as an unsigned base-two integer—so one-zero-one-zero-one-zero is forty-two, not a sequence of BCD nibbles—and only then maps each decimal place into 8421 form. Forty-two therefore becomes the two nibbles zero-one-zero-zero and zero-zero-one-zero, while two hundred fifty-five becomes the three nibbles for two, five, and five.
That is not the same as treating the original bits as already-packed BCD, and it is not pure binary either: pure binary for two hundred fifty-five is eight ones, while BCD keeps three separate digit groups so humans and seven-segment hardware can drive each digit independently. If you already have a decimal digit string and only need BCD packing, use a decimal BCD converter; if you only need the base-ten value of a binary string, use a binary-to-decimal converter.
This page is for the combined path that firmware and display labs actually ask for.
How the binary field is read and how results stay reproducible
The value must be a non-negative whole binary quantity given as zeros and ones—no minus signs, no fractional points, no hexadecimal letters. Outer whitespace is trimmed, an optional zero-b or zero-B prefix is stripped, and spaces, underscores, or hyphens between bits are ignored so strings such as one-zero-one-zero space one-zero parse the same as the compact form. Leading zeros are normalized away while preserving a lone zero, so several zero-padded register dumps collapse to the same canonical binary and the same BCD result.
Conversion uses a left-to-right Horner scan: start at zero and for each bit replace the running value with twice that value plus the new bit, which is exactly the place-value sum of each bit times a power of two. The intermediate magnitude must remain a safe non-negative integer within the declared bit and digit ceilings; oversized strings fail closed rather than rounding. Each resulting decimal digit is then emitted as its four-bit 8421 pattern and concatenated.
Where binary-to-BCD conversion fits in study, hardware, and software
Students meet binary-to-BCD when a digital-logic course wires a counter to a seven-segment decoder, when a computer-architecture lab asks how a binary register value becomes digit-wise display codes, or when an exam contrasts pure binary, BCD, and Gray encodings. Teachers can pre-generate answer keys for modest bit lengths without trusting opaque calculator apps that confuse binary strings with already-packed BCD or that accept illegal digit codes.
Embedded and industrial engineers check BCD display drivers, multi-digit LED modules, PLC panels, and protocol fields that still store each decimal place as a nibble while upstream logic still thinks in pure binary. Developers call the same contract from scripts to seed deterministic test vectors for parsers, to validate user-entered binary strings before programming a display, or to satisfy programming-challenge statements that demand packed 8421 rather than a hand-waved sketch.
Product and education tools use the conversion when a learner types a binary value and the UI must show the decimal magnitude, the compact BCD bit string, and the spaced nibble view immediately. Pair it with pure binary-to-decimal or decimal BCD tools when you are building a small lab of free, deterministic number-format converters for digital literacy and firmware debugging.
What you can do with it
Seven-segment display labs
Convert a binary counter or register value into 8421 BCD nibbles before wiring multi-digit seven-segment drivers in digital-logic labs.
Firmware and BCD panel dumps
Turn pure binary magnitudes from registers into digit-wise BCD patterns used by industrial displays, PLC panels, and BCD counters.
FAQ
What does the binary to BCD converter cost?
It is free in your browser on this page.
How is this different from a decimal BCD converter?
This tool starts from a pure binary bit string, interprets its base-2 magnitude, then packs each decimal digit as 8421 BCD. A decimal BCD converter starts from base-ten digits you already have.
What is 8421 BCD?
Each decimal digit 0–9 is stored as a 4-bit nibble with bit weights 8, 4, 2, and 1. Multi-digit numbers concatenate those nibbles in digit order for seven-segment and similar hardware.
Are spaces or a 0b prefix allowed in the binary string?
Yes. Outer whitespace is trimmed, an optional 0b/0B prefix is stripped, and spaces, underscores, or hyphens between bits are ignored.
Are negative numbers or fractions supported?
No. Only non-negative whole binary integers within the supported bit and digit ceilings are accepted.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/binary-to-bcd \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"binary":"101010"}'const res = await fetch("https://api.kit.forhosting.com/elec/binary-to-bcd", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"binary": "101010"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/binary-to-bcd",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"binary": "101010"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/binary-to-bcd", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"binary":"101010"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"binary":"101010"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/binary-to-bcd", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"binary": "101010"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.binary_to_bcd",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_bits | 50 |
max_digits | 15 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
What binary-to-BCD means and what the response contains
The response returns the canonical binary string and binary_bits length, the decimal integer and decimal_string, a compact bcd bit string with no separators, a bcd_spaced string with a space between nibbles, the nibbles array, the digits array, nibble_count, bit_length, a method tag binary_to_8421_bcd, the encoding label 8421, and a short formula reminder. There is no approximate path and no silent coercion of illegal input: empty values, non-binary characters, negative numbers disguised as text, and bit strings longer than the supported ceiling are rejected with invalid_input.
How the binary field is read and how results stay reproducible
The preferred field is binary for the base-two payload, but aliases bin, value, text, input, bits, n, and number are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing binary decoding and 8421 tables yourself.
Where binary-to-BCD conversion fits in study, hardware, and software
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic test fixtures
Generate reproducible binary→BCD bit strings and decimal echoes for unit tests, property checks, and CI assertions.