Octal to Hex Converter

5×8=40
7×8⁰1=7
total=47

Show the working for hex → octal

Going the other way? Convert hex back to octal

How do you convert octal to hex?

Octal to hex conversion passes through binary: each octal digit becomes its bit group, the bits are regrouped, and each new group becomes one hexadecimal digit.

  1. Write each octal digit as three binary digits.
  2. Join the bits into one run: 57 is 101111.
  3. Regroup that run into fours from the right, padding the left group.
  4. Replace each group with its hexadecimal digit: 57 = 2F.

Octal to Hexadecimal Conversion Table

One hexadecimal digit equals exactly 4 bits (16 = 2⁴); one octal digit equals exactly 3 bits (8 = 2³). Hex and octal are therefore converted by grouping bits, and hex ↔ octal passes through binary. That is the whole method, so the table below is the only thing you need: every group of 4 bits has exactly one hex digit, and the mapping never changes. Binary writes values on the digit set 0, 1 with each place worth 2ⁿ, and a value marked 0b is binary; hex values are marked 0x.

Octal to Hexadecimal Conversion Table
4 bitsHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15

Each base is defined by three things: which digits it uses, how a value is marked, and what each position is worth.

Base reference
BaseRadixDigits PrefixPlace worthTypical range
Octal80–7 0o8ⁿ3 digits cover a byte (000–377); Unix permissions 000–777
Hexadecimal160–9, A–F (A=10 … F=15; case-insensitive) 0x16ⁿ2 digits cover a byte (00–FF); 6 digits = RGB colour; 8 digits = 32-bit word

Worked Example: 57 to Hexadecimal

One value, converted the long way so the working is visible. This is the same grid the converter shows when you turn on "show steps".

5×8=40
7×8⁰1=7
total=47

Result: 57 = 2F

Both bases here are powers of two, so no division is needed. One hexadecimal digit is worth exactly 4 bits, which means the conversion is a regrouping of the same bits rather than a change of value.

Written out, 57 is 101111 in binary. Regrouping those bits into 4s from the right, and padding the leftmost group with zeros if it is short, gives 2F. Counting the groups from the left instead is where this goes wrong: the padding then lands on the wrong end and every digit shifts.

Check it in reverse

The value returns unchanged. Convert 2F back and you get 57, because a base change rewrites the digits without touching the quantity they stand for. That is the whole test: if the round trip differs, a digit was misread. To check it by hand, convert the octal result back to hex and compare it with the number you started from.

Worked examples: octal to hex

Each example gives the value first, then the working. Click a value to load it in the converter.

What is 0o777 in hexadecimal?

0o777 in octal is 1FF in hexadecimal.

Method: regroup the bits in fours; 777 is 111111111 in binary.

Load this value in the converter

What is 0o57 in hexadecimal?

0o57 in octal is 2F in hexadecimal.

Method: regroup the bits in fours; 57 is 101111 in binary.

Load this value in the converter

What is 0o472 in hexadecimal?

0o472 in octal is 13A in hexadecimal.

Method: regroup the bits in fours; 472 is 100111010 in binary.

Load this value in the converter

What is 0o12 in hexadecimal?

0o12 in octal is A in hexadecimal.

Method: regroup the bits in fours; 12 is 1010 in binary.

Load this value in the converter

What is 0o144 in hexadecimal?

0o144 in octal is 64 in hexadecimal.

Method: regroup the bits in fours; 144 is 1100100 in binary.

Load this value in the converter

What is 0o377 in hexadecimal?

0o377 in octal is FF in hexadecimal.

Method: regroup the bits in fours; 377 is 11111111 in binary.

Load this value in the converter

What is 0o10 in hexadecimal?

0o10 in octal is 8 in hexadecimal.

Method: regroup the bits in fours; 10 is 1000 in binary.

Load this value in the converter

What is 0o20 in hexadecimal?

0o20 in octal is 10 in hexadecimal.

Method: regroup the bits in fours; 20 is 10000 in binary.

Load this value in the converter

What is 0o40 in hexadecimal?

0o40 in octal is 20 in hexadecimal.

Method: regroup the bits in fours; 40 is 100000 in binary.

Load this value in the converter

What is 0o100 in hexadecimal?

0o100 in octal is 40 in hexadecimal.

Method: regroup the bits in fours; 100 is 1000000 in binary.

Load this value in the converter

What is 0o200 in hexadecimal?

0o200 in octal is 80 in hexadecimal.

Method: regroup the bits in fours; 200 is 10000000 in binary.

Load this value in the converter

What is 0o14 in hexadecimal?

0o14 in octal is C in hexadecimal.

Method: regroup the bits in fours; 14 is 1100 in binary.

Load this value in the converter

Every example above reverses exactly — regroup the same bits from four to three at a time.

What About Padding, Fractions and Width?

Leading zeros and width

A number carries no leading zeros unless a width is fixed. 2F and 02F are the same value, so the converter writes the short form. Fixed widths belong to bytes and registers, not to arithmetic. repeated division and positional expansion covers where width does matter.

Fractions and the point

Digits after a point convert by the same rule with negative powers, so the first place after the point is worth 1/16. Many fractions that end neatly in decimal repeat forever in binary, which is where rounding creeps in.

Negative values

A minus sign is kept in front of the digits. Fixed-width binary encodes sign differently, using two's complement, and that is a separate rule from the base change itself.

How large a value can be

The method has no ceiling; each extra octal digit multiplies the range by 8. Practical limits come from the width a machine stores the value in, not from the conversion.

Octal to Hex in Code

The same rule in one line. Both route through binary and return the hexadecimal digits.

Python: format(int('57', 8), 'X')
JavaScript: parseInt('57', 8).toString(16).toUpperCase()

Common Mistakes

Frequently Asked Questions

How many octal digits equal one hex digit?

None exactly. The two only line up at 12 bits, where 4 octal digits equal 3 hex digits. One hexadecimal digit equals exactly 4 bits (16 = 2⁴); one octal digit equals exactly 3 bits (8 = 2³). Hex and octal are therefore converted by grouping bits, and hex ↔ octal passes through binary.

Can you give octal to hex practice questions with answers?

Yes. Work these out: 17 = F, 57 = 2F, 100 = 40, 472 = 13A and 777 = 1FF. Expand each octal digit to 3 bits, regroup the bits in fours from the right, then read each group as one hex digit.

How do you convert octal to hex in Python?

Read the digits as base 8, then format the value in base 16: format(int('57', 8), 'X') returns 2F. 0b marks binary, 0o octal, 0x hexadecimal; a leading # marks a hex colour. Hexadecimal is not case-sensitive (FF = ff); iToolHub writes hex digits in uppercase.

Binary sits in the middle either way, so the same value converts straight back in the hex to octal direction.

The rest of the family sits on back to the binary converter.