Decimal to Binary Converter — Instant Base-10 to Base-2
Convert decimal numbers to binary instantly. Arbitrary precision via BigInt, clean grouped output. Free, runs entirely in your browser.
Supports arbitrary-precision integers via BigInt — no 2⁵³ overflow. Handles negative numbers and the standard 0b/0o/0x prefixes. All conversion happens in your browser.
Converting decimal to binary, explained
Decimal (base 10) is the counting system humans grew up with; binary (base 2) is the language of digital circuits. Converting a decimal number to binary means rewriting it using only the digits 0 and 1. This decimal to binary converter handles the conversion instantly in your browser with arbitrary precision via JavaScript BigInt — paste a 20-digit decimal number and get the exact binary string back.
The conversion algorithm
To convert a decimal number to binary by hand, divide by 2 repeatedly and collect the remainders. Read the remainders in reverse order. For example, converting decimal 22:
22 ÷ 2 = 11 remainder 0 ← lowest bit 11 ÷ 2 = 5 remainder 1 5 ÷ 2 = 2 remainder 1 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1 ← highest bit Reading remainders bottom-to-top: 1, 0, 1, 1, 0 Result: 10110
So decimal 22 equals binary 10110. The tool above does this automatically and handles any input size.
How to use this decimal to binary converter
- Type or paste a decimal (base-10) integer into the decimal field.
- The binary field updates live with the base-2 equivalent. Hex and octal also appear for reference.
- Binary output has no leading zeros — so decimal 4 becomes
100, not00000100. Pad it yourself if you need a fixed bit width. - Scientific notation, commas, and decimal fractions are not supported — integer input only.
Examples
Decimal Binary 0 0 1 1 2 10 7 111 10 1010 16 10000 127 1111111 128 10000000 255 11111111 # one full byte 256 100000000 65535 1111111111111111 # uint16 max
When you need decimal to binary
- Understanding bit flags. A configuration value of 13 in the docs becomes
1101, which tells you flags 0, 2, and 3 are set. - Writing bit masks from a spec. An ISA manual gives a value as decimal 42; you need the binary version to compare with an instruction encoding table.
- Subnet math. A subnet mask like /24 corresponds to 255.255.255.0, whose last octet is
00000000and whose first three are all11111111. - Teaching number systems. First-year computing courses live on decimal-to-binary conversions — this tool shortcuts homework verification.
- Debugging low-level code. Your compiler emitted an opcode that came out as decimal 143; the reference table is in binary.
Powers of 2 — the quick reference
2⁰ = 1 2¹ = 2 2² = 4 2³ = 8 2⁴ = 16 2⁵ = 32 2⁶ = 64 2⁷ = 128 (8 bits, one byte boundary) 2⁸ = 256 2⁹ = 512 2¹⁰ = 1024 (1 KiB) 2¹⁶ = 65536 (uint16 max + 1) 2³² = 4294967296 (uint32 max + 1)
Memorizing the first ten powers of 2 speeds up mental conversion. Any decimal number can be decomposed as a sum of these, with each chosen power contributing a 1 at its position in the binary output.
Why computers store everything as binary
Digital logic gates have exactly two stable voltage states: high and low. Interpreting those as 1 and 0 turns the circuit into a binary computer. Ternary and decimal computers have been built as research projects, but binary is the universal standard because it maps cleanly to transistor physics and error detection is simple (any deviation from high-or-low is an error). Everything above the transistor layer — ints, floats, Unicode text, images, network packets — is an encoding on top of bit strings.
Privacy
This decimal to binary converter runs entirely in your browser. Values are parsed and converted locally using BigInt — no server, no network, no logging. Paste any value without worry.
Frequently asked questions
Does the binary output have leading zeros?
No. The tool outputs the minimum bit string, so decimal 4 is 100, not 00000100. Pad it to 8, 16, 32, or 64 bits yourself if you need a fixed width.
Can I convert fractions or decimals to binary?
This tool converts integers only. Fractional decimal-to-binary is well-defined (e.g. 0.5 decimal → 0.1 binary, 0.1 decimal → 0.0001100110011... repeating) but rarely needed outside of teaching floating-point representation. For floating-point values, use IEEE 754 encoding.
Is there a maximum decimal value?
No practical limit. The tool uses BigInt, so a 100-digit decimal converts correctly without rounding.
How do I convert decimal to binary in code?
JavaScript: n.toString(2). Python: bin(n) (returns with0b prefix) or f'{n:b}'. C: use repeated division with %2 or a library.
How do I convert a negative decimal to binary?
Negative numbers are represented in two's complement at a fixed bit width. For 8-bit signed: compute 256 + value, then convert. For example, -1 as 8-bit signed is 11111111(because 256 + (-1) = 255, which is 11111111 in binary). This tool handles unsigned only; apply the two's complement step yourself.
Related tools
- Number BaseConvert numbers between binary, octal, decimal, and hexadecimal instantly. Live bidirectional conversion with explanations — free, runs in your browser.
- Binary to DecimalConvert binary numbers to decimal instantly. Arbitrary precision, handles any bit-width. Free, runs in your browser — no ads, no signup.
- Decimal to HexConvert decimal numbers to hexadecimal instantly. Arbitrary precision via BigInt, outputs lowercase hex. Free, runs entirely in your browser.