Number Base Converter

Convert binary, octal, decimal, hex and any base 2–36, with two's complement

Digits 0–9
Digits 0–1
Digits 0–7
Digits 0–9, A–F
Digits 0–9, A–Z
Grouping: binary in 4s, hex in 2s (with leading zeros), octal in 3s, decimal Indian style (1,00,000).
Decimal value
255
Type in any field; the others update instantly.
Bits needed
8
Bytes
1
Decimal digits
3
Sign
Positive
Two's complement (fixed width)
WidthAs signedAs unsignedHexBinary
8-bit-1255FF1111 1111
16-bit25525500 FF0000 0000 1111 1111
32-bit25525500 00 00 FF0000 0000 0000 0000 0000 0000 1111 1111
64-bit25525500 00 00 00 00 00 00 FF0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111
“As signed” reads the same bits as a two's complement number (e.g. FF in 8-bit is −1); “as unsigned” reads them as a plain positive number (255).

Runs entirely in your browser. Nothing you type or upload is sent to us or stored.

Results are for general guidance. Please check anything important before relying on it. Terms of use

How to Use

  1. Type a whole number into any box: Decimal, Binary, Octal, Hexadecimal or the Base N box. Prefixes like 0x, 0b and 0o are fine, and so are spaces and underscores.
  2. The other boxes update as you type. If you enter a digit the base doesn't allow (such as 2 in binary), a red message tells you which digits are valid.
  3. Pick any base from 2 to 36 in Any other base to convert to base 3, base 32, base 36 and so on.
  4. Switch on Group digits to show binary in groups of 4, hex in pairs and decimal with Indian commas. Use ± Change sign for negative numbers.
  5. Scroll to the Two's complement table to see the 8, 16, 32 and 64-bit patterns, and the same bits read as signed and unsigned values. Tap Copy next to any box to copy it.

What is a number base?

The base (or radix) is how many different digits a number system uses. This number base converter moves a number between any two bases from 2 to 36. We count in base 10, with digits 0–9. Computers store everything in base 2 (binary, digits 0 and 1). Programmers use base 16 (hexadecimal, 0–9 and A–F) and base 8 (octal, 0–7) as compact ways to write binary, because one hex digit is exactly 4 bits and one octal digit is exactly 3 bits. Bases above 10 borrow letters, so base 36 uses all of 0–9 and A–Z.

In every base, each position is worth the base times the position to its right:

value = dₙ×bⁿ + … + d₂×b² + d₁×b¹ + d₀×b⁰
9C (base 16) = 9×16 + 12×1 = 156
234 (base 8) = 2×64 + 3×8 + 4 = 156

Worked example: 156 to binary

Divide by 2 again and again, writing down each remainder, then read the remainders from bottom to top:

156 ÷ 2 = 78 r 0
78 ÷ 2 = 39 r 0
39 ÷ 2 = 19 r 1
19 ÷ 2 = 9 r 1
9 ÷ 2 = 4 r 1
4 ÷ 2 = 2 r 0
2 ÷ 2 = 1 r 0
1 ÷ 2 = 0 r 1 → 156 = 1001 1100 (binary)

Now group the bits: in fours from the right, 1001 = 9 and 1100 = 12 = C, so the hex value is 9C. In threes, 010 011 100 gives octal 234. Type 156 into the Decimal box and switch on Group digits to see the same result.

Negative numbers and two's complement

Ordinary maths writes a negative number with a minus sign, and so does this converter in every base (−156 is −9C in hex). A computer, though, stores signed integers in a fixed number of bits using two's complement: write the positive value in binary, flip every bit, then add 1.

−5 in 8 bits: 5 = 0000 0101 → flip → 1111 1010 → +1 → 1111 1011 = FB

The same 8 bits FB mean −5 when read as a signed byte and 251 when read as unsigned (251 − 256 = −5). The two's complement table in the tool shows both readings for 8, 16, 32 and 64 bits, or the allowed range if the number does not fit:

WidthSigned rangeUnsigned rangeCommon names
8-bit−128 to 1270 to 255byte, int8, uint8
16-bit−32,768 to 32,7670 to 65,535short, int16
32-bit−2,147,483,648 to 2,147,483,6470 to 4,294,967,295int, int32
64-bit−9,223,372,036,854,775,808 to 9,223,372,036,854,775,8070 to 18,446,744,073,709,551,615long, int64

Where you meet other bases

  • Colour codes: #2F6FED is three hex bytes: red 2F = 47, green 6F = 111, blue ED = 237.
  • Linux file permissions: chmod 755 is octal; 7 = 111 = rwx for the owner, 5 = 101 = r-x for group and others.
  • Networking: the subnet mask 255.255.255.0 is 24 ones followed by 8 zeros in binary, which is why it is written /24.
  • Memory addresses, MAC addresses and hashes are written in hex.
  • Base 36 is used for short IDs and URL codes because it packs large numbers into few characters (1,295 is just ZZ).

Very large numbers

Many online converters use JavaScript's normal numbers. Those are exact only up to 2⁵³ (9,007,199,254,740,992), and anything bigger gets rounded without warning. This converter uses BigInt arithmetic, so a 64-bit value, a 128-bit hash or a 1,000-digit number converts exactly.

Tips

  • You can paste values with prefixes (0xFF, 0b1010, 0o17), spaces, underscores or Indian commas (1,00,000).
  • Only whole numbers are converted. Fractions such as 10.5 aren't supported.
  • Base64 (used for encoding files as text) isn't a number base in this sense. Use the Base64 encoder for that.

Frequently Asked Questions

Type the number in the Decimal box and the binary value appears straight away. By hand, divide by 2 repeatedly and read the remainders from last to first: 13 gives remainders 1, 0, 1, 1, so 13 = 1101 in binary.

Type the hex value (with or without 0x) in the Hexadecimal box. By hand, multiply each digit by a power of 16 and add them: FF = 15×16 + 15 = 255, and 1A3 = 1×256 + 10×16 + 3 = 419.

It's how computers store negative integers in a fixed number of bits. Write the positive number in binary, invert every bit and add 1. So −1 in 8 bits is 1111 1111 (FF) and −128 is 1000 0000 (80). The tool shows the 8, 16, 32 and 64-bit patterns for any number that fits.

Because it depends on how you read it. FF is the bit pattern 1111 1111. Read as an unsigned byte it's 255; read as a signed 8-bit two's complement number it's 255 − 256 = −1. The bits don't change, only the reading does, which is why the table shows both 'as signed' and 'as unsigned'.

Yes. It uses BigInt arithmetic, so numbers far beyond the 2^53 limit of ordinary JavaScript numbers convert exactly, up to about 4,000 digits. Only whole numbers are supported, not fractions.

It's the number system that uses the digits 0–9 and the letters A–Z, the largest base you can write with ordinary letters and digits. It's handy for short codes: the number 1,295 is just ZZ. Choose any base from 2 to 36 in the Any other base box.