Decimal to Binary Converter: Fast & Simple Conversion

Binary result:

The method: repeated division by 2

Converting a decimal integer to binary means repeatedly dividing by 2 and reading the remainders from bottom to top. Each division tells you whether that binary position is a 0 or a 1.

Worked example: 45

DivisionQuotientRemainder
45 ÷ 2221
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading the remainders bottom to top gives 101101. Entering 45 into this converter returns exactly that, because it calls JavaScript's Number.toString(2), which produces the same base-2 digit string without the intermediate steps shown.

Input handling

The field expects a whole number. An empty box returns "Please enter a number"; a non-numeric entry (like text or a stray symbol) returns "Invalid input" instead of a wrong conversion. Decimal fractions get truncated by parseInt before conversion, so 45.9 converts the same as 45.