Binary Converter

Binary Converter

Type a number, say which base it is in, and get it in binary, decimal, octal and hexadecimal at once — with the number of bits, the binary padded to whole bytes, and the division steps behind the conversion. Any size of non-negative whole number works.

Spaces and underscores are ignored; 0b, 0o and 0x prefixes are accepted.
Binary11111111
Decimal255
Octal377
HexadecimalFF
Bits8
Bytes needed1
Padded to full bytes1111 1111

Each 1 in 11111111 marks a power of 2: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Hex groups the bits in fours (1111 1111) and octal in threes.

Decimal to binary: repeated division by 2
DivideQuotientRemainder (bit)
255 ÷ 21271
127 ÷ 2631
63 ÷ 2311
31 ÷ 2151
15 ÷ 271
7 ÷ 231
3 ÷ 211
1 ÷ 201
Read the bits from the bottom up: 11111111

Calculated on your device · formulas checked against known results · How we test

How to use the binary converter

Type the number, choose the base it is written in, and press Convert. You get the same value in binary, decimal, octal and hexadecimal, each with a copy button, plus the number of bits it needs, the binary padded to whole bytes in groups of four, and — for decimal, octal and hex input — the divide-by-2 table that produces the binary digits.

Place values in base 2

Decimal digits count ones, tens, hundreds and thousands. Binary digits (bits) count powers of 2 instead: from the right, 1, 2, 4, 8, 16, 32, 64, 128. A bit is either 0 or 1, so a binary number is simply a list of which powers of 2 to add. 11111111 has all eight bits set: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest value a byte (8 bits) can hold. A number needs one more bit each time it passes a power of 2 — 256 is the first 9-bit number.

Decimal to binary: divide by 2

Divide the number by 2, write down the remainder (0 or 1), and repeat with the quotient until it reaches 0. The remainders read from last to first are the binary digits. For 37:

  1. 37 ÷ 2 = 18 remainder 1
  2. 18 ÷ 2 = 9 remainder 0
  3. 9 ÷ 2 = 4 remainder 1
  4. 4 ÷ 2 = 2 remainder 0
  5. 2 ÷ 2 = 1 remainder 0
  6. 1 ÷ 2 = 0 remainder 1

Reading upward gives 100101. Check: 32 + 4 + 1 = 37.

Binary to decimal

Add the place values of the bits that are 1. For 100101, the 1s sit in the 32, 4 and 1 positions: 32 + 4 + 1 = 37.

Hexadecimal and binary: one hex digit per four bits

Hexadecimal (base 16) uses the digits 0–9 and the letters A–F for 10–15. Because 16 = 2⁴, every hex digit stands for exactly four bits, which makes converting between the two a matter of looking up groups:

HexBinaryHexBinaryHexBinaryHexBinary
000004010081000C1100
100015010191001D1101
2001060110A1010E1110
3001170111B1011F1111

So 1FF in hex is 0001 1111 1111 in binary, and 1010 0110 in binary is A6 in hex. A byte is always exactly two hex digits (00 to FF), which is why programmers prefer hex to long strings of bits: memory addresses, color codes like #FF8800 (red FF, green 88, blue 00), MAC addresses and file dumps are all written in hex.

Octal: three bits per digit

Octal (base 8) uses the digits 0–7, and each one stands for three bits. 777 in octal is 111 111 111 in binary — 511 in decimal and 1FF in hex. Octal survives mainly in Unix file permissions, where each digit holds the read, write and execute bits for one group: chmod 755 means 111 101 101, or rwxr-xr-x.

Worked example: FF in every base

FF (hex) → each F is 1111, so the binary is 11111111. Adding the place values gives 255 in decimal. Grouping the same bits in threes from the right, 011 111 111, gives 377 in octal. The number uses 8 bits, exactly one byte.

Frequently asked questions

How do I write a negative number in binary?

Computers use two's complement inside a fixed width: flip every bit of the absolute value and add 1. In 8 bits, −1 is 11111111 and −128 is 10000000 — the same bit patterns as 255 and 128 unsigned, so the width and the convention must be agreed in advance. This converter handles non-negative whole numbers only.

Can I convert a fraction or decimal point to binary?

Not with this tool. Fractions use negative powers of 2 after a binary point (0.1 in binary = 1/2, 0.01 = 1/4), and many decimal fractions never terminate in binary — 0.1 in decimal is 0.000110011… — which is why 0.1 + 0.2 is not exactly 0.3 in floating-point arithmetic.

What is the largest number that fits in 8, 16, 32 or 64 bits?

2 to the power of the width, minus 1: 255 for 8 bits, 65,535 for 16, 4,294,967,295 for 32 and 18,446,744,073,709,551,615 for 64.

What do the 0b, 0o and 0x prefixes mean?

They mark the base in most programming languages: 0b for binary, 0o for octal and 0x for hexadecimal, so 0b11111111, 0o377, 0xFF and 255 are the same value. The converter accepts and strips the prefix that matches the base you selected.

How many bits does a number need?

Find the largest power of 2 that is not bigger than the number and add 1 to its exponent: 255 is less than 2⁸ = 256, so it fits in 8 bits; 256 needs 9. The Bits row shows this count, and Bytes rounds it up to whole bytes of 8.

Embed this calculator on your website

Free for any website or blog. Paste this code where you want the calculator to appear:

All free calculator widgets

Last updated: October 9, 2026

Menu

Categories

Finance Calculators22 calculatorsBusiness & Shopping Calculators6 calculatorsHealth & Fitness Calculators9 calculatorsMath & School Calculators19 calculatorsDate & Time Calculators10 calculatorsHoliday Countdowns16 calculatorsEveryday Tools15 calculators

CalcWorthy

AboutContactPrivacy PolicyTerms of Use

Language

Language
EnglishEnglishالعربيةArabicবাংলাBanglaDeutschGermanEspañolSpanishفارسیPersianFrançaisFrenchעבריתHebrewहिन्दीHindiBahasa IndonesiaIndonesianItalianoItalian日本語Japanese한국어KoreanBahasa MelayuMalayNederlandsDutchPolskiPolishPortuguêsPortugueseРусскийRussianไทยThaiTürkçeTurkishУкраїнськаUkrainianاردوUrduTiếng ViệtVietnamese简体中文Simplified Chinese