Take an ordinary base-10 integer and rewrite it as a string of 0s and 1s. The page runs everything through JavaScript BigInt, so values far above 253 still convert without rounding errors. Negatives and decimals are rejected on purpose.

Decimal ⇄ Binary Converter

Mode:
Options:
0 / 100,000 chars

How decimal to binary works

Repeatedly divide the decimal number by 2 and write down the remainder. Reading the remainders from the last division back to the first gives the binary digits. For example, 13 → 1101 (13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1).

Quick examples

DecimalBinary
00
101010
42101010
25511111111
102410000000000

How to use

  1. Type a non-negative whole number (no minus sign, no decimal point) into Input.
  2. The binary string appears in Output with no leading zeros. Pad manually if you need a fixed byte width.
  3. Need the reverse? Click Binary → Decimal at the top, or use Swap.
  4. Hit Copy to grab the result. Processing is entirely local.

Real-world use cases

  • Building bitmasks. When firmware code reads or writes individual hardware-register bits — interrupt flags, permission bits, feature toggles — turning the desired decimal mask into binary tells you which positions get a 1.
  • Subnet and netmask reasoning. A netmask like 255.255.255.0 is really four bytes, three of which translate to 11111111. Converting the octets to binary makes it obvious that the prefix length is 24, and the same trick exposes off-by-one mistakes in /27 versus /28.
  • IoT and embedded encoding. Squeezing a sensor reading into a fixed bit field — say, 10 bits for temperature inside a 32-bit telemetry word — starts by turning the value into binary and checking it fits the budget.
  • Teaching the divide-by-2 algorithm. Students who run the converter alongside paper division learn faster than from a textbook table, because the tool confirms each remainder.
  • Truth tables and digital logic. Before writing the output column, students enumerate input combinations 0..7 as 000..111; the converter is a quick sanity check.
  • CTF and puzzle payloads. Many challenges hide a flag or coordinate inside a long bit string. Encoding the target as binary, then comparing to the puzzle output, is a standard first step — feed the result back through Binary to Decimal to verify the round trip.

How decimal turns into binary — the divide-by-2 method

Every positive integer has exactly one base-2 representation, and the textbook way to find it is the divide-by-2 method: keep dividing by 2, keep the remainders (each is a 0 or 1), and read the remainders bottom to top. With 13 you get 13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1 — read upwards and the answer is 1101. The remainders are forced to be 0 or 1 because that is what division by 2 produces, which is why the algorithm works for any base by simply changing the divisor.

The idea of writing numbers with only two digits goes back a long way. Gottfried Wilhelm Leibniz laid out a systematic positional binary notation in 1703 in his paper Explication de l'Arithmétique Binaire, complete with addition and multiplication tables. For more than two centuries the notation was a curiosity, until George Stibitz built the Model K relay adder at home in 1937 and Konrad Zuse finished the mechanical, binary-by-design Z1 in 1938. ENIAC, completed in 1945, was famously a decimal machine, but every general-purpose computer that followed it leaned on binary internally — partly because Shannon's 1937 master's thesis had shown that relay circuits realised Boolean algebra cleanly.

All conversion in this tool runs through JavaScript BigInt, so the divide-by-2 chain works on arbitrary-precision integers — a 40-digit decimal converts exactly, with no silent rounding around 253. If you tick the Signed (two's complement) checkbox and pick a bit width, the encoder also accepts negatives: -128 at 8 bits becomes 10000000, the same bit pattern you'd see in a CPU register or a signed byte field on the wire.

Worked examples

Click each example to expand the step-by-step trace:

10 → 1010 (the smallest "looks like decimal" case)

10÷2=5 r0, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1. Reading the remainders from bottom to top: 1010. The output happens to look like the decimal 1010, which is a classic source of "wait, did it even convert?" confusion — they are different numbers in different bases.

255 → 11111111 (largest unsigned byte)

255 is 28−1, so its binary form is eight 1s. Any value from 0 to 255 fits in a single byte; 256 needs nine bits and rolls into 100000000. This is also why one octet of an IPv4 address tops out at 255.

1024 → 10000000000 (a clean power of two)

1024 is 210, so the binary form is a single 1 followed by ten zeros — eleven bits in total. Powers of two are the easiest sanity check for any conversion routine, and they demonstrate that the BigInt path stays exact past byte boundaries.

-128 (signed, 8-bit) → 10000000

Tick Signed, choose 8-bit, then enter -128. The result is 10000000 — the same bit pattern an unsigned 128 would have, but interpreted as a signed byte it is −128 because the top bit carries weight 27. That overlap is the whole point of two's complement: addition and subtraction work on the bit pattern without any sign-handling branch in hardware.

Common pitfalls

  • Negatives are refused by default. Plain base-2 has no sign, so the tool rejects -5 unless you switch into signed mode by ticking Signed (two's complement) and picking a bit width.
  • Signed mode needs a bit width. Once signed is on, the converter has to know whether you mean an 8-, 16-, 32-, or 64-bit field. Values outside the range — -129 at 8 bits, or 200 at 8 bits — are rejected instead of being silently truncated.
  • No fractional input. 0.5 and 3.14 are not integers, so the tool refuses them. Real-number conversion is an IEEE-754 problem, not a base-conversion one.
  • BigInt removes the 253 ceiling. Plain JavaScript Number starts to lose precision above 253, but this converter routes the value through BigInt, so a 30-digit decimal still produces an exact bit string.
  • Thousands separators are not parsed. 1,024 with a comma is rejected; type 1024 instead. Stray whitespace at the ends is tolerated, but embedded punctuation is not.

Need to go the other way? The binary to decimal converter reverses every example above, and the binary to hex converter compresses 8-bit groups into two hex digits when the binary form gets unwieldy. For converting plain English to and from binary instead of numeric values, hop over to the binary code translator.

Frequently asked questions

How do I convert a decimal number like 42 to binary by hand?

Divide repeatedly by 2 and collect remainders bottom-up: 42÷2=21 r0, 21÷2=10 r1, 10÷2=5 r0, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1. Reading bottom to top gives 101010.

Does this tool support fractional decimals like 0.625?

No — only non-negative integers. Fractional binary (e.g. 0.101) requires IEEE-754 floating-point context and isn't covered by this converter.

Can I convert negative numbers?

Not directly. The tool rejects negative input because plain binary has no sign. For signed values you must choose a representation (sign-magnitude, two's complement) and a bit-width first.

What is the largest decimal I can enter?

Any positive integer that fits in 100,000 characters. The output uses BigInt so a 30-digit decimal still converts cleanly — no silent rounding above 2^53.

Why does 10 become 1010 instead of 0000 1010?

The minimal binary representation drops leading zeros by default. If you need a fixed bit-width (e.g. 8 bits per byte), pad the result manually with leading zeros.

How do I enable signed (two's complement) output?

Tick the Signed checkbox that appears under Options once Decimal → Binary mode is active, then pick a bit width (8/16/32/64). The converter will then accept negatives and encode them as two's complement — for example −1 in 8-bit becomes 11111111, and −128 becomes 10000000. Leave the box unchecked for plain magnitude output.

Why is 3.14 rejected even though my calculator accepts it?

This is an integer-only converter. Real numbers like 3.14 or 0.5 need IEEE-754 floating-point context (sign bit, exponent, mantissa) which is a different problem than base conversion — so the tool refuses fractional input instead of silently dropping the part after the dot.

How does the converter handle numbers larger than 2^53?

It uses JavaScript BigInt throughout, so there is no 53-bit precision ceiling. A 50-digit decimal converts exactly, with no rounding and no scientific-notation surprises. The only practical limit is the 100,000-character input cap.