Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal and any base.

What the Number Base Converter does

A number’s value is independent of the base you write it in — only the notation changes. Converting means repeatedly dividing by the target base and reading the remainders, which is why hexadecimal and binary line up so neatly at four bits per digit.

Formula

  • Value = Σ digitᵢ × baseⁱ
  • To convert: divide by the target base, collect remainders, read them in reverse
  • 1 hex digit = 4 binary digits; 1 octal digit = 3 binary digits
  • Bits needed = ⌊log₂(value)⌋ + 1

Inputs explained

InputUnitRequiredNotes
ValuetextYesPrefixes such as 0x, 0b and 0o are accepted and ignored.
Input baseone of 5 optionsYes
Custom input basenumberIn some modesAccepts 2 or more, up to 36. Shown Input base is Custom base.
Extra output basenumberOptionalAny base from 2 to 36, shown alongside the standard four. Accepts 2 or more, up to 36.
Bit widthone of 4 optionsYes

How to use it

  1. Choose Input base and Bit width.
  2. Enter Value.
  3. Fill in the remaining inputs the form shows for your choice.
  4. Optionally add Extra output base.
  5. Select Calculate.

Worked example

Converting the decimal number 255.

Value
255
Input base
Decimal

255 is 0xFF in hex, 0b11111111 in binary and 0o377 in octal — eight set bits, exactly one byte.

Frequently asked questions

Why is hexadecimal used so much in programming?

Because one hex digit is exactly four bits, so a byte is always two hex digits. Reading 0xFF is far easier than 0b11111111 and maps directly onto the underlying bits.

What is the largest value a byte can hold?

255 unsigned (0xFF), or −128 to 127 signed in two’s complement. Eight bits give 256 distinct values either way.

Related calculators