Convert Decimal to Binary

Convert decimal numbers to binary instantly, one value or a whole list at a time. Free, client-side converter with copy and download options.

Encode decimal integers as binary with full support for negatives via two's complement, sign-magnitude, or one's complement. Choose bit width (8/16/32/64), grouping, and 0b prefix. BigInt under the hood for arbitrary size.

How to Use Convert Decimal to Binary

  1. Enter decimals, one per line. Positive, negative, and arbitrarily large values are all supported (BigInt under the hood).
  2. Pick a representation for negatives. Two's complement (default) is what CPUs use - -5 in 8-bit is 11111011. Sign-magnitude shows -101. One's complement is the bitwise invert. Unsigned rejects negatives.
  3. Choose bit width. Auto uses the minimum bits needed. Fixed widths pad shorter values with leading zeros and reject values that overflow the chosen range.
  4. Optional grouping breaks the output every 4, 8, or 16 bits with a space - easier to read long binary strings. Prefix prepends 0b, 0B, or % for paste-into-code convenience.
  5. Enable the breakdown for debugging - each input value gets its own row showing decimal, bit count, representation, and width.
  6. Convert (Ctrl+Enter). Live preview runs after 150 ms. Invalid lines are reported per-line; valid lines still produce output.

Frequently Asked Questions

Why are there four ways to represent a negative number in binary?

Because binary itself doesn’t have a “−” sign – computers have to pick a convention. The four common ones: sign-magnitude (first bit = sign), one’s complement (negatives are bitwise-flipped positives), two’s complement (one’s complement + 1, has a unique zero), and offset binary. Two’s complement won because addition and subtraction are the same circuit, which saves transistors.

Why is -5 in 8-bit two’s complement 11111011?

Because two’s complement defines negative n as 2^width − n. For 8-bit: 256 − 5 = 251 = 11111011. Equivalently, take +5 (00000101), flip all bits (11111010), and add 1 (11111011). Both methods agree.

What does “bit width auto” produce?

The minimum number of bits to hold the value under the chosen representation. Unsigned 10 → 4 bits (1010). Signed 10 → 5 bits (01010) so the leading 0 signals positive. Signed −10 → 5 bits (10110). Fixed widths override this and pad with leading zeros.

What happens if my number overflows the chosen bit width?

You get a specific error like “overflow: 128 exceeds signed 8-bit range [-128, 127]”. Unsigned 8-bit allows 0-255; signed 8-bit allows -128 to 127. The tool doesn’t silently truncate because that would hide a real bug.

Why does one’s complement need a fixed width?

Because the representation is “bitwise invert of the absolute value” – you need a width to know how many bits to invert. Without a width, -5 could be 010-inverted (101) or 0101-inverted (1010) or wider, and all are ambiguous. Two’s complement has the same issue but the auto-width heuristic (pick min bits + 1) disambiguates.

Can I convert really big numbers?

Yes – the logic uses BigInt, so 2^128 or a 200-digit decimal both encode correctly. There’s no 2^53 precision cliff that plain Number.toString(2) would hit. Stats show the actual bit count even for huge inputs.

Can I convert decimal fractions like 0.75?

No – this tool is integer-only. Fractional binary (e.g., 0.75 = 0.11 binary) uses a radix point and is typically stored as IEEE 754 float (sign + exponent + mantissa). For that, use a floating-point-to-bits converter.

What’s the 0b prefix for?

Convenience when pasting into code. Python (0b1010), Rust (0b1010), C23, and Java 7+ all accept it. Assembly sometimes uses % instead. Turn prefix off when you just want raw bits.

Does the tool handle 2^63 correctly (the signed 64-bit boundary)?

Yes. Signed 64-bit max is 2^63 − 1 = 9,223,372,036,854,775,807. Signed 64-bit min is −2^63 = −9,223,372,036,854,775,808. Both encode exactly. Values outside this range return the overflow message with the exact allowed range in the error.

Is the tool free, offline, and private?

Yes. All arithmetic happens in your browser using native JavaScript and BigInt. No upload, no tracking, no account. Load the page once and it keeps working offline indefinitely.