Guide

How to Convert Numbers Between Binary, Octal, Decimal and Hex

Understand number bases, how conversion works, and why hex and binary are everywhere in computing.

A number base converter translates a value between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). These bases underpin how computers represent and display numbers.

What number bases are

A base is the number of distinct digits used to represent values. Decimal uses 10 digits (0–9), binary uses 2 (0–1), octal uses 8 (0–7), and hex uses 16 (0–9 and A–F). The same quantity can be written in any base: decimal 255 is binary 11111111 and hex FF.

How conversion works

To convert from any base to decimal, multiply each digit by the base raised to its position and sum. To convert from decimal to another base, repeatedly divide by the target base and read the remainders upwards. Hex is a shorthand for binary: each hex digit maps to exactly 4 bits, which is why programmers use it to read binary compactly.

How to use the converter

  1. Enter a number and choose its base.
  2. Choose the target base.
  3. Read the converted value.

Examples

Decimal 42 = binary 101010 = octal 52 = hex 2A. Hex colour #FFFFFF is binary 111111111111111111111111 — three bytes of 255. The byte 0xAB is decimal 171.

When a number base converter is useful

  • Reading or writing colour codes, memory addresses, or bitmasks.
  • Learning or teaching computer science.
  • Debugging values shown in hex in developer tools.
  • Converting between bases for embedded systems work.

Put it into practice

Use the Number/Base Converter right now — free, in your browser, no sign-up required.

Try the Number/Base Converter