Binary Converter: Binary, Decimal, Hexadecimal and Octal

Type a number in any of the four boxes and the other three follow, with the place values added up for you. A second panel turns text into binary and back.

TechFreeNo sign-upWorks on phones
Binary to decimal working
0Bits needed
0Bytes needed
0Decimal digits
Text to binary and back
–

This tool runs in your browser. Nothing you type is uploaded or saved, and there is nothing to install or sign up for.

Four number systems, one value

Computers store everything as patterns of two states, on and off, which is why binary sits underneath all of computing. People find long rows of ones and zeros hard to read, so programmers shorten them with hexadecimal or, less often, octal, and everyone else counts in decimal. All four are different spellings of the same quantity.

This binary converter links the four spellings. Type in the Binary, Decimal, Hexadecimal or Octal box and the remaining three are rewritten as you go. Below them, the binary digits are expanded into the powers of two they stand for and added up, so you can see why the answer is what it is. A separate panel converts ordinary text to the bytes a computer stores for it.

How to convert a number

  1. Click the box for the base you are starting from and type the number. Spaces and underscores are ignored, and the prefixes 0b, 0x and 0o are accepted.
  2. Read the other three boxes. Hexadecimal letters are shown in capitals.
  3. Tick Show binary in groups of four to split a long binary number into easy-to-read blocks.
  4. Check Binary to decimal working for the place values.
  5. Press Copy all four for a one-line summary, or Reset to return to the example.

For text, type in the Text box to get binary, or paste groups of eight bits into the binary box to read them as characters.

Worked example: 45 in every base

The page starts with decimal 45. Its binary form is 101101, and the working line reads:

101101 = 32 + 0 + 8 + 4 + 0 + 1 = 45

Each binary digit has a place value that doubles as you move left: 1, 2, 4, 8, 16, 32 and so on. A 1 means that place value is counted and a 0 means it is skipped. Here the 32, 8, 4 and 1 places are switched on.

To build the binary by hand from decimal, divide by 2 over and over and note the remainders: 45 gives 22 remainder 1, 22 gives 11 remainder 0, 11 gives 5 remainder 1, 5 gives 2 remainder 1, 2 gives 1 remainder 0, and 1 gives 0 remainder 1. Read the remainders from last to first and you have 101101.

Hexadecimal comes from cutting the binary into fours from the right: 0010 and 1101. The first block is 2 and the second is 13, written D, so 45 is 2D in hex. Octal uses blocks of three: 101 and 101 are 5 and 5, giving 55. The tool shows all of these at once, and reports that 45 needs 6 bits, which fits in a single byte.

Place values at a glance

Bit position from the right1st2nd3rd4th5th6th7th8th
Place value1248163264128

Eight bits make a byte. With all eight switched on, 11111111, the place values add up to 255, which is FF in hexadecimal and 377 in octal. One more, 256, needs a ninth bit and so a second byte. That is why values such as 255 and 256 keep turning up in computing, including the 0 to 255 range of each channel in a color code, which you can explore with the HEX to RGB color converter.

Text to binary: what the second panel does

Characters are stored as numbers too. The panel uses UTF-8, the encoding used by most web pages, and writes each byte as eight binary digits. The starting text, Hi!, becomes:

01001000 01101001 00100001

Capital H is number 72 (64 + 8), small i is 105 and the exclamation mark is 33. Plain English letters, digits and punctuation take one byte each. Accented letters and other symbols take two or more: the letter e with an acute accent is stored as the two bytes 11000011 10101001. Going back, the binary must come in complete bytes, so the number of digits has to be a multiple of 8.

Limits and frequent mistakes

  • A digit that does not belong to the base. Binary has no 2, octal has no 8 or 9, and hexadecimal stops at F. The tool names the offending character instead of guessing.
  • Whole numbers of zero or more only. Negative values, fractions and decimal points are not converted. Signed formats such as two’s complement depend on a chosen bit width and are outside this page.
  • Leading zeros do not change the value. 00101101 and 101101 are the same number; the grouping option adds zeros only for readability.
  • Mixing up the two panels. The digit 5 as a number is 101 in binary, but the character 5 typed as text is the byte 00110101, because text stores the code of the symbol, not its value.
  • Size. Numbers up to 256 digits long are accepted in current browsers. A browser without big-integer support is limited to 9,007,199,254,740,991, and says so.

Classroom and study ideas

For a computing lesson, hide the screen, give students a binary number of six or eight digits and have them write the place values above each digit before adding. Reveal the working line to check. Reverse the task with the repeated-division method. Spelling a short name in the text panel and decoding a partner’s message makes the idea of character codes concrete.

The same thinking about bits explains why longer passwords are stronger, which the password generator reports as bits of entropy. For other ways of writing numbers, try the Roman numeral converter or the number to words converter.

More helpers like this are listed under tech and web tools, and the whole set of free online tools is on the main tools page.

Frequently asked questions

How do you convert binary to decimal?

Give each binary digit a place value that doubles from right to left (1, 2, 4, 8 and so on), then add the place values wherever the digit is 1. For 101101 that is 32 + 8 + 4 + 1, which is 45.

How do you convert decimal to binary?

Divide the number by 2 repeatedly and write down each remainder, then read the remainders from last to first. Doing this with 45 gives 101101.

What is 255 in binary?

255 is 11111111 in binary, eight ones. It is the largest value one byte can hold, and it is FF in hexadecimal and 377 in octal.

How do I convert binary to hexadecimal?

Split the binary number into groups of four digits starting from the right and convert each group to one hex digit. 101101 becomes 0010 and 1101, which is 2 and D, so the answer is 2D.

How is text written in binary?

Each character is stored as one or more bytes, and each byte is written as eight binary digits. In UTF-8 the text Hi! is 01001000 01101001 00100001.

Can this converter handle negative numbers or fractions?

No. It converts whole numbers of zero or more. Negative and fractional binary formats depend on extra rules such as a fixed bit width, so they are not covered here.

Related tools

Browse all free tools →