Binary, Hex & Octal Converter

Convert any number between decimal, binary, hexadecimal and octal, with the place-value breakdown shown for each.

How to use this calculator

  1. 1Choose the base your number is currently in.
  2. 2Enter the value using the correct digits for that base.
  3. 3All four representations are shown together, so you can read off whichever you need.

How the calculation works

value = Σ digitᵢ × baseⁱ
digitᵢ
The digit at position i, reading from the right
base
2 for binary, 8 for octal, 16 for hexadecimal
i
The position, starting at 0 on the right

Every positional number system works the same way — decimal is simply base 10. Binary, octal and hex are bases 2, 8 and 16, chosen because they relate cleanly to how computers group bits (8 bits = 1 byte = 2 hex digits).

Converting to a target base repeatedly divides by that base and collects the remainders; converting from a base sums each digit times its place value.

Worked example

255 in decimal

  1. 1.255 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 — every power of 2 up to 128.
  2. 2.In binary that is 11111111 (eight 1s).
  3. 3.In hex: 255 ÷ 16 = 15 remainder 15, so it is FF (15 is F in hex).

Result: Binary 11111111, hex FF, octal 377

What binary and hexadecimal number systems are

Every number system represents value using a base — how many distinct digits it has before a position rolls over. Decimal, the everyday system, is base 10: ten digits (0–9), and the tenth value in any position rolls over to the next. Binary is base 2, using only 0 and 1; hexadecimal is base 16, using 0–9 and then A–F for the values 10 through 15. The underlying idea is identical across all of them — a digit’s value depends on both the symbol and its position — only the base, and therefore how quickly positions roll over, changes.

Why computing is built on base 2

Binary isn’t an arbitrary choice — it maps directly onto how digital electronics work. A transistor is fundamentally a two-state switch, reliably on or off, and building hardware around two clean, well-separated voltage states is far more reliable than trying to distinguish ten different voltage levels precisely. Every value a computer stores or processes, at the lowest level, is ultimately a sequence of these on/off states — bits — and every other representation, decimal, hex or otherwise, is a human-facing convenience built on top of that binary substrate.

Why hex and octal exist at all

If computers only need binary, hexadecimal and octal earn their place purely for human convenience:

  • Compactnesseach hex digit represents exactly 4 bits (one "nibble"), so a byte — 8 bits — is always exactly 2 hex digits. Reading FF is far faster and less error-prone than reading 11111111, while the conversion between the two is mechanical.
  • Memory addresses and color codeshexadecimal is the standard way to write memory addresses in debuggers and colors in CSS and design tools (#FF5733), precisely because it is compact and converts cleanly to and from binary.
  • Bitwise flags and permissionssystems that pack several true/false settings into one number — Unix file permissions (chmod 755), network flags, feature bitmasks — are far more legible in octal or hex than as a long, undifferentiated string of binary digits.
  • Octal’s narrower roleoctal (base 8) is less common today but persists in Unix file permissions and some legacy systems, where each digit conveniently represents exactly 3 bits.

Where conversions commonly go wrong

A handful of small errors account for most base-conversion mistakes:

  • Misreading look-alike charactershexadecimal’s letters can be mistaken for digits at a glance — 0 (zero) versus O, or a stray B read as 8 — an easy transcription error when copying a hex value by hand.
  • Fixed-width overflowbinary and hex values stored in a fixed number of bits (8, 16, 32) can silently wrap around or misrepresent a value if it exceeds what that width can hold — a classic source of integer-overflow bugs.
  • Sign representationnegative numbers in binary aren’t simply "minus" written in front — real systems use conventions like two’s complement, which this tool’s unsigned arithmetic mode deliberately doesn’t attempt to replicate.

What this assumes, and where it stops

Assumptions

  • Values are whole numbers, positive or negative.

Limitations

  • Limited to values representable exactly as JavaScript integers — up to about 9 quadrillion.

Common questions

Why do programmers use hexadecimal instead of binary?

Because it is dramatically more compact while still mapping cleanly onto binary — every hex digit corresponds to exactly 4 bits, so a byte (8 bits) is always exactly 2 hex digits. Reading FF is far easier than reading 11111111, but the conversion between them is trivial in a way that decimal is not.

How do I convert binary to decimal by hand?

Write down the powers of 2 above each bit, starting from 1 on the right and doubling each place: 1, 2, 4, 8, 16… Add up the powers of 2 wherever the bit is 1. For 1011, that is 8 + 0 + 2 + 1 = 11.

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the binary, hex & octal converter.

See all developer tools calculators →