Encoding 🔒 Runs in your browser — no data sent to servers

Number Base Converter

Convert between binary, decimal, hex, octal and any base up to 36, and turn text into binary or hex and back.

Number Base Converter - Binary, Decimal, Hex and Octal

Type a number and see it in binary, octal, decimal and hexadecimal at the same time, plus any other base from 2 to 36. Prefixes are understood, so 0xFF, 0b1010 and 0o17 just work, numbers of any size convert exactly, and a negative number also shows its two's complement. A second tab turns text into binary or hex bytes and back.

It is the everyday tool for reading a hex dump, setting file permissions in octal, checking a bit mask, or answering a homework question about binary, and it runs entirely in your browser.

How to convert a number

  1. Type the number. With Input base on Automatic (0x, 0b, 0o or decimal), the prefix decides the base; otherwise choose it.
  2. Read the Binary, Octal, Decimal and Hexadecimal rows, which update as you type.
  3. Tick Group digits for readability, and set Also show base for any base up to 36.
  4. Copy any row with its button.

The four common bases

BaseDigitsExample (decimal 255)Where you see it
Binary (2)0 and 111111111Bits, flags, masks, networking
Octal (8)0 to 7377Unix file permissions such as 755
Decimal (10)0 to 9255Everyday numbers
Hexadecimal (16)0 to 9 and A to FFFColours, memory addresses, byte dumps, hashes

How the conversion works

A number in base b is a sum of digits times powers of b. Binary 101010 is 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42. Going the other way, you divide by the base again and again and read the remainders backwards: 42 ÷ 2 leaves 0, 21 ÷ 2 leaves 1, 10 ÷ 2 leaves 0, 5 ÷ 2 leaves 1, 2 ÷ 2 leaves 0 and 1 ÷ 2 leaves 1, giving 101010. Hexadecimal and binary are closely linked because 16 is 2 to the power 4: each hex digit is exactly four bits, so F is 1111 and 2A is 0010 1010.

No size limit

Many converters quietly round numbers above 2 to the power 53, the largest integer a JavaScript number holds exactly, or stop at 64 bits. This one uses arbitrary-precision integers, so a 128-bit ID, a 256-bit key written in hex or 2 to the power 64 (18446744073709551616) converts digit for digit. The line under the results shows the bit length and byte length of the number you typed.

Negative numbers and two's complement

For a negative number, the rows show the value with a minus sign, and two extra rows show how a computer stores it: its two's complement at the smallest common width it fits in, 8, 16, 32, 64 or 128 bits. -1 is 11111111 or FF in 8 bits, and -129 needs 16 bits, where it is FF7F. This is what you see in a debugger or a hex dump when a signed integer is negative.

Text to binary and back

The Text tab converts text into the bytes that represent it, in UTF-8. Choose Text to numbers, pick Binary, Hexadecimal, Decimal or Octal, and Hi becomes 01001000 01101001 or 48 69. Letters outside basic English take two to four bytes each, so é is C3 A9. Numbers to text goes the other way and accepts bytes separated by spaces or commas, or run together in fixed-width groups.

Input tips

  • Spaces, underscores and apostrophes inside a number are ignored, so 1_000_000 and FF FF both work.
  • Digits above 9 are the letters A to Z, in either case, which is how bases up to 36 are written.
  • Only whole numbers convert. Fractions such as 0.1 often have no exact form in another base, so any result would be rounded.
  • A digit that does not exist in the chosen base, such as 2 in binary, is reported instead of being skipped.

Related tools

For colours written in hex, the colour converter turns #FF8800 into RGB, HSL and more. For whole files or strings as Base64 rather than binary or hex, use the Base64 encoder. The task pages open this converter for one job: binary to decimal, decimal to binary, hex to decimal and text to binary.