Skip to content
Hexadecimal Converter

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.

Method: Through binary: four bits to three
Write each hex digit as 4 bits
Hex digitBits
10001
F1111
40100
Regroup in 3s from the point outward (pad: no zeros on the left)
GroupOctal digit
1117
1106
1004

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.

  1. Expand every hex digit into its four bits.
  2. Join the bits and drop any zeros at the very front.
  3. Split the bits into groups of three, starting from the right, and pad the leftmost group with zeros.
  4. 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

Write each hex digit as 4 bits
Hex digitBits
10001
F1111
40100
Regroup in 3s from the point outward (pad: no zeros on the left)
GroupOctal digit
1117
1106
1004

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.

0x1ED split into its three permission classes
ClassBitsOctalMeaning
Owner1117rwx
Group1015r-x
Others1015r-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.

Permission modes
HexOctalSymbolicTypical use
1ED755rwxr-xr-xprograms and directories
1A4644rw-r--r--ordinary files
180600rw-------private keys and secrets
1FF777rwxrwxrwxopen 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.

Last updated