Skip to content

Decimal to Binary Converter

Turn decimal integers into binary, including negative numbers as two’s complement at the bit width you need.

Processed locally in your browser

Options

Two’s complement writes a negative number as a fixed-width bit pattern (range −2^(N−1) … 2^N−1).

One number per line. Spaces and underscores inside a number are ignored.0 chars · 0 lines
The result will appear here.

What is Decimal to Binary Converter?

Binary writes a number using only 0 and 1, each position worth a power of two: decimal 42 is 101010 because 32 + 8 + 2 = 42. This tool converts each line you paste with exact big-integer arithmetic, so it is not limited to 32 or 53 bits.

Negative numbers can be shown with a minus sign (−101) or as a fixed-width two’s complement bit pattern, the way CPUs store signed integers: −5 in 8 bits is 11111011. You can also group the bits in nibbles or bytes, add a 0b prefix and pad to whole bytes.

How does it work?

  1. Paste one decimal integer per line.
  2. Choose how negatives are written: a minus sign, or two’s complement in 8, 16, 32 or 64 bits.
  3. Set grouping (4 or 8 bits), the 0b prefix and padding to a multiple of 8, 16, 32 or 64 bits.
  4. Copy the result; for a single number the rows also show hex, octal and the bit length.

Common use cases

  • Checking bit flags and masks while reading or writing low-level code.
  • Seeing how a negative integer is stored in an int8, int16 or int32 variable.
  • Preparing binary literals for hardware registers or protocol fields.
  • Verifying answers for computer-science exercises.

Examples

Try this input in the tool above:

Input
42
-5
255
Output
101010
-101
11111111

Privacy

Decimal to Binary Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Two’s complement needs a fixed width, so values must fit the range from −2^(N−1) to 2^N−1; anything outside is reported as an error on that line. Fractions are not handled here; use the Base Converter.

Frequently asked questions

How is −5 written in two’s complement?

Invert the bits of 5 and add one. In 8 bits: 00000101 → 11111010 → 11111011. Choose “Two’s complement, 8-bit” to see it directly.

Is there a size limit?

No practical limit for normal use: numbers of thousands of digits convert exactly. Only two’s complement modes are limited to their bit width.

How do I get a full byte for small numbers?

Set “Pad to a multiple of” to 8 bits, so 5 becomes 00000101 instead of 101.

More tools in Developer Tools →