Hex to Octal Converter
Going the other way? Convert octal back to hex →
How do you convert hex to octal?
Hex to octal conversion passes through binary: each hexadecimal digit becomes its bit group, the bits are regrouped, and each new group becomes one octal digit.
Hex 2F is octal 57. Expand each hex digit to 4 bits (2 = 0010, F = 1111), regroup the bits in threes from the right (101 111), and convert each group to an octal digit.
- Write each hexadecimal digit as four binary digits.
- Join the bits into one run: 2F is 101111.
- Regroup that run into threes from the right, padding the left group.
- Replace each group with its octal digit: 2F = 57.
Hexadecimal to Octal 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.
| 4 bits | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
Each base is defined by three things: which digits it uses, how a value is marked, and what each position is worth.
| Base | Radix | Digits | Prefix | Place worth | Typical range |
|---|---|---|---|---|---|
| Hexadecimal | 16 | 0–9, A–F (A=10 … F=15; case-insensitive) | 0x | 16ⁿ | 2 digits cover a byte (00–FF); 6 digits = RGB colour; 8 digits = 32-bit word |
| Octal | 8 | 0–7 | 0o | 8ⁿ | 3 digits cover a byte (000–377); Unix permissions 000–777 |
Worked Example: 2F to Octal
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".
Result: 2F = 57
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, 2F is 101111 in binary. Regrouping those bits into 4s from the right, and padding the leftmost group with zeros if it is short, gives 57. 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 57 back and you get 2F, 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 hex result back to octal and compare it with the number you started from.
Worked examples: hex to octal
Each example gives the value first, then the working. Click a value to load it in the converter.
What is 0xFF in octal?
0xFF in hexadecimal is 377 in octal.
Method: regroup the bits in fours; FF is 11111111 in binary.
What is 0x2F in octal?
0x2F in hexadecimal is 57 in octal.
Method: regroup the bits in fours; 2F is 101111 in binary.
What is 0xA in octal?
0xA in hexadecimal is 12 in octal.
Method: regroup the bits in fours; A is 1010 in binary.
What is 0x64 in octal?
0x64 in hexadecimal is 144 in octal.
Method: regroup the bits in fours; 64 is 1100100 in binary.
What is 0x8 in octal?
0x8 in hexadecimal is 10 in octal.
Method: regroup the bits in fours; 8 is 1000 in binary.
What is 0x10 in octal?
0x10 in hexadecimal is 20 in octal.
Method: regroup the bits in fours; 10 is 10000 in binary.
What is 0x20 in octal?
0x20 in hexadecimal is 40 in octal.
Method: regroup the bits in fours; 20 is 100000 in binary.
What is 0x40 in octal?
0x40 in hexadecimal is 100 in octal.
Method: regroup the bits in fours; 40 is 1000000 in binary.
What is 0x80 in octal?
0x80 in hexadecimal is 200 in octal.
Method: regroup the bits in fours; 80 is 10000000 in binary.
What is 0xC in octal?
0xC in hexadecimal is 14 in octal.
Method: regroup the bits in fours; C is 1100 in binary.
What is 0xF in octal?
0xF in hexadecimal is 17 in octal.
Method: regroup the bits in fours; F is 1111 in binary.
What is 0x14 in octal?
0x14 in hexadecimal is 24 in octal.
Method: regroup the bits in fours; 14 is 10100 in binary.
Every example above reverses exactly — regroup the same bits from three to four at a time.
What About Padding, Fractions and Width?
Leading zeros and width
A number carries no leading zeros unless a width is fixed. 57 and 057 are the same value, so the converter writes the short form. Fixed widths belong to bytes and registers, not to arithmetic. what a base is and why position matters 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/8. 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 hexadecimal digit multiplies the range by 16. Practical limits come from the width a machine stores the value in, not from the conversion.
Hex to Octal in Code
The same rule in one line. Both route through binary and return the octal digits.
Python: format(int('2F', 16), 'o') JavaScript: parseInt('2F', 16).toString(8) Common Mistakes
- Reading the remainders top to bottom. They come out in reverse, so the digits land backwards.
- Using a digit the base does not have — an 8 in octal, or a 2 in binary. The value cannot be read at all.
- Grouping bits from the left. Groups are counted from the right, and the leftmost group is the one that gets padded.
- Treating the result as a character code. 41 is a number here, not the letter A.
Frequently Asked Questions
How do you convert a hex number with a decimal point to octal?
Expand each digit to 4 bits, then regroup in threes outward from the point. 2F.8 is 00101111.1000 in binary; the bits left of the point group to 101 111 and the bits right of it to 100, giving 57.4.
Why is there no direct hex to octal method?
Because a hex digit (0–9, A–F) is 4 bits and an octal digit (0–7) is 3; the two never line up. 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 convert hex to octal through decimal?
Yes, though it takes longer. 2F is 47 in decimal, and dividing 47 by 8 twice gives 57. Through binary there is no division at all: 2F is 00101111, which regroups in threes as 101 111 = 57.
Both bases are powers of two, so the same value converts straight back in the octal to hex direction.
Related Conversions
The rest of the family sits on every conversion in this family.