Tech

Number base converter

Type a number, pick its source base, and instantly see its equivalent in binary, octal, decimal, hexadecimal and any base you want (2 to 36).

Instant🔒In your browserNo signup
Live

What is a number base

A number base (or positional system) defines how many distinct symbols are used to write numbers. In base 10 (decimal) there are ten digits, 0 to 9. In base 2 (binary) there are only two: 0 and 1. The value of each digit depends on its position: in 255, the 2 is worth 200 because it sits in the hundreds place. Changing base means writing the same value with a different digit alphabet.

How conversion works

The trick is to always go through an intermediate point: the raw numeric value. First the number is interpreted in its source base to get that value (with parseInt(number, base)), then it is rewritten in the target base (with value.toString(base)). That is why 255 decimal, FF hexadecimal and 11111111 binary are the same number: they share the value, only the representation changes.

The four key bases

The same decimal value 255 looks very different depending on the base. This table sums it up:

BaseNameDigits255 in decimal
2Binary0 111111111
8Octal0-7377
10Decimal0-9255
16Hexadecimal0-9 A-FFF
36Base 360-9 A-Z73
  • Binary (2): the machine's native language, only 0 and 1.
  • Octal (8): groups bits in threes; classic in Unix permissions (chmod 755).
  • Decimal (10): the one people use every day.
  • Hexadecimal (16): compact; two digits = one byte. Colors, memory, hashes.

Why hexadecimal uses letters

Base 16 needs sixteen symbols, but we only have ten digits (0-9). They are completed with the letters A, B, C, D, E and F, worth 10, 11, 12, 13, 14 and 15. So a number like 2A means 2×16 + 10 = 42. Universal convention: always uppercase to avoid confusion, as we do in this tool.

Real-world uses by field

  • Colors: the CSS #FF5733 is three bytes (red, green, blue) in hexadecimal.
  • Permissions: chmod 755 uses octal, where each digit is three permission bits.
  • Networking: subnet masks and MAC addresses are read in binary and hexadecimal.
  • Low level: memory addresses, dumps and bit flags in hexadecimal.
  • Hashes and IDs: MD5, SHA and many identifiers are shown in hexadecimal.

Arbitrary bases up to 36

Beyond the four classics, you can convert to any base from 2 to 36. Base 36 uses the ten digits and the twenty-six letters (0-9, A-Z), and is used to shorten identifiers: a long number in decimal takes far fewer characters in base 36. It is the ceiling supported by the JavaScript toString function.

FAQ

What is a number base?

How many distinct digits a system uses: decimal 10, binary 2, hexadecimal 16. The same value is written in any base.

How do you convert between bases?

Interpret the number in its source base to get the decimal value, then rewrite it in the target base.

Why does hex use letters?

It needs 16 symbols; A-F represent 10 to 15. That is why 255 decimal is FF.

What about an invalid digit?

It is validated against the chosen base and an error is shown, never a NaN. A 2 in binary or a G in hex is rejected.

What is binary used for?

It is the machine's native language: bits, flags, masks, permissions and logical operations.

Where is hexadecimal used?

CSS colors, memory, MAC addresses, hashes and debugging. Two hex digits are one byte.

What is the highest base?

Up to base 36 (0-9 and A-Z), the limit of toString in JavaScript.

Was this generator useful?