Hex to Octal Converter
To convert hex to octal, write each hex digit as four bits, then regroup the bits in threes from the right and read each group as one octal digit. For example, 1F4 is 0001 1111 0100 in binary; regrouped as 111 110 100 it gives 764. Both are 500 in decimal.
Repeats forever:
Repeats forever:
Method: Through binary: four bits to three
| Hex digit | Bits |
|---|---|
| 1 | 0001 |
| F | 1111 |
| 4 | 0100 |
| Group | Octal digit |
|---|---|
| 111 | 7 |
| 110 | 6 |
| 100 | 4 |
Result: 764.
How to convert hex to octal by hand
Hex digits carry four bits and octal digits carry three, so the digits do not line up one to one. Binary is the common ground: write the bits once, then cut them differently. It avoids decimal entirely and never needs division.
- Expand every hex digit into its four bits.
- Join the bits and drop any zeros at the very front.
- Split the bits into groups of three, starting from the right, and pad the leftmost group with zeros.
- Read each three-bit group as one octal digit, 000 = 0 through 111 = 7.
Twelve bits, three hex digits, regroup into exactly four octal digits, which makes three-digit hex values the easiest case. For longer values the boundaries line up again every twelve bits, so you can convert a long string in chunks of three hex digits at a time.
Worked example: 1F4
Twelve bits, regrouped into threes
1F416 = 7648 = 50010
| Hex digit | Bits |
|---|---|
| 1 | 0001 |
| F | 1111 |
| 4 | 0100 |
| Group | Octal digit |
|---|---|
| 111 | 7 |
| 110 | 6 |
| 100 | 4 |
Result: 764.
Unix permissions: where hex meets octal
File modes are the main place octal survives. Each permission class, owner, group and others, has three switches: read, write and execute. Three bits per class is one octal digit per class, which is why chmod 755 reads so naturally. The POSIX specification of chmod defines these absolute modes as octal numbers, one bit per permission.
Tools that print the raw mode as an integer sometimes show it in hex. 0x1ED looks unfamiliar until you expand it: 1 1110 1101, regrouped as 111 101 101, is 755, the familiar rwxr-xr-x. The same trick decodes a mode from a hex dump of an archive header.
| Class | Bits | Octal | Meaning |
|---|---|---|---|
| Owner | 111 | 7 | rwx |
| Group | 101 | 5 | r-x |
| Others | 101 | 5 | r-x |
Common modes in both notations
These four cover most of what you set by hand. In each, the octal digits are the permissions and the hex is the same nine bits read four at a time, which scrambles the classes across digit boundaries. That scrambling is the reason permissions are written in octal.
| Hex | Octal | Symbolic | Typical use |
|---|---|---|---|
| 1ED | 755 | rwxr-xr-x | programs and directories |
| 1A4 | 644 | rw-r--r-- | ordinary files |
| 180 | 600 | rw------- | private keys and secrets |
| 1FF | 777 | rwxrwxrwx | open to everyone (rarely wise) |
Questions people ask
Can you convert hex to octal directly?
Not digit by digit, because one hex digit is four bits and one octal digit is three. The easy route is through binary: expand each hex digit to four bits, then regroup the bits in threes from the right.
What is FF hex in octal?
377. FF is 11111111 in binary; regrouped from the right as 11 111 111 it reads 3, 7, 7. Both are 255 in decimal.
How do hex values map to Unix file permissions?
Permissions are three octal digits, for the owner, the group and everyone else. 0x1ED is 111 101 101 in binary, which is octal 755, or rwxr-xr-x: the owner can read, write and execute, and everyone else can read and execute.
Why does octal use three bits per digit?
Because 8 = 2³. Three bits cover the values 0 to 7, exactly the eight octal digits, just as four bits cover the sixteen hex digits.
Related conversions
Last updated