Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36. Works with very large numbers.

Decimal (base 10)
Hexadecimal (base 16)
Binary (base 2)
Octal (base 8)
Other base:

How to convert between binary, decimal and hex

  1. Type into whichever box matches the number you have: decimal, hexadecimal, binary, octal, or the Other base box after choosing any base from 3 to 36 in its menu (base 36 is preselected).
  2. Every other box updates as you type. There is no direction to choose; any box can be the input.
  3. Use the Copy button beside the result you need. Untick Uppercase letters if you prefer ff to FF.

The line under the boxes shows how many bits the number needs and how many bytes that rounds up to – useful when choosing a field size. Input is forgiving: 0x, 0b and 0o prefixes are accepted in the matching box, letters can be upper or lower case, a leading minus sign works, and spaces, underscores and commas are ignored, so 1111 0000, 0xDEAD_BEEF and 1,000,000 are all fine. An invalid character produces a message naming it, such as “2” in a binary number.

How positional number systems work

In any base b, each digit is worth b times the digit to its right. Decimal 255 means 2×100 + 5×10 + 5×1. The same quantity in hexadecimal is FF: 15×16 + 15×1. In binary it is 11111111: eight ones, each worth twice the one before. Bases above 10 borrow letters for the extra digits, A = 10 up to Z = 35, which is why 36 is the highest base the converter offers.

  • Binary (base 2) mirrors how hardware stores data: every digit is one bit.
  • Octal (base 8) groups bits in threes. Today it mostly survives in Unix file permissions.
  • Hexadecimal (base 16) groups bits in fours, so one byte is always exactly two hex digits. That makes it the standard way to write memory addresses, byte dumps, hashes and colors.
  • Base 36 uses every digit and letter, giving short, case-insensitive IDs; it appears in URL shorteners and some reference codes.

Worked examples

DecimalHexBinaryOctalWhere you meet it
255FF1111 1111377Largest value of one byte
2561001 0000 0000400Needs 9 bits, so 2 bytes
4931ED111 101 101755chmod 755: rwx r-x r-x
3735928559DEADBEEF32 bits33653337357A classic debugging marker
16746496FF880024 bits77704000The color #FF8800

The permissions example shows why octal suits Unix: each octal digit is exactly three bits – read, write, execute – for owner, group and others. In the color example, the pairs FF, 88 and 00 are the red, green and blue bytes 255, 136 and 0; the Color Converter does that split for you.

Large values are exact. The converter uses arbitrary-precision integers, so 2⁶⁴ − 1 = 18446744073709551615 becomes FFFFFFFFFFFFFFFF (64 bits, 8 bytes) with no rounding. Many calculators and spreadsheets silently lose digits beyond about 15–16 significant figures, and Excel’s DEC2BIN refuses anything outside −512 to 511.

Converting by hand

Decimal to binary: divide by 2 repeatedly and write the remainders from last to first. For 156: 156→78 r0, 78→39 r0, 39→19 r1, 19→9 r1, 9→4 r1, 4→2 r0, 2→1 r0, 1→0 r1, so 156 = 10011100. The same method works for any base; divide by 16 for hex and you get 9C.

Hex to decimal: multiply each digit by 16 raised to its position, counting from 0 on the right: 2F = 2×16 + 15 = 47.

Binary to hex: split the bits into groups of four from the right and translate each group: 1001 1100 → 9 and C → 9C. For octal, use groups of three.

Negative numbers and two’s complement

The converter writes negative numbers with a minus sign: −42 is -2A in hex and -101010 in binary. Computers usually store them differently, in two’s complement, where the pattern depends on the width of the field. To find it, add 2ⁿ for an n-bit field and convert the result: for 8 bits, 256 − 42 = 214, which is D6 or 11010110; for 16 bits, 65536 − 42 = 65494, which is FFD6. Going the other way, if the top bit of an n-bit value is 1, subtract 2ⁿ to get the signed value: FF as a signed byte is 255 − 256 = −1.

FAQ

Can I convert fractions such as 0.5?

No, only whole numbers. A decimal point is reported as an invalid digit. Many decimal fractions, like 0.1, have no finite binary representation at all, which is the root of floating-point rounding surprises.

Why does 0x appear in code but not in the result?

0x, 0b and 0o are notation telling a programming language which base follows; they are not part of the number. Add the prefix your language expects when you paste the value.

How many bits do I need to store a number?

The status line shows it directly. As a rule, n bits hold unsigned values from 0 to 2ⁿ − 1, so 255 fits in 8 bits and 256 needs 9.

Is “10” in base 36 the same as decimal 10?

No. In base 36, 10 means 1×36, so it is decimal 36, and ZZ is 35×36 + 35 = 1295. Always say which base a number is in when you share it.