Hexadecimal to Octal Converter – Free

This hex to octal converter rewrites a base-16 number in base 8. For example, 2d becomes 55 and the file mode 1ED becomes 755.

How to use the Hexadecimal to Octal tool

  1. Enter the hex value, such as 2d or a mode like 1ED, in the Base-16 number box.
  2. Select Convert to rewrite it in base 8.
  3. Read the octal digits, 0 to 7, in the Result box.
  4. Select Copy to copy the result. Add a leading 0 or 0o in your code if the language requires an octal prefix.

How hex to octal conversion works

Hex and octal are both shorthand for binary, but they group bits differently. A hex digit covers four bits and an octal digit covers three. Since four is not a multiple of three, digits do not map one to one. The practical method is to expand the hex number to binary and regroup the bits in threes starting from the right.

The tool reaches the same answer arithmetically: it parses the hex digits into one integer and writes that integer in base 8.

Hex      1    E    D
Binary   0001 1110 1101
Regroup  000 111 101 101
Octal      0   7   5   5   ->  755

Hex to octal examples from real systems

Octal survives in two places most developers touch: Unix permission bits and the octal escape sequences of C, shell and many other languages. Debuggers and hex dumps show the same values in hex, so this conversion bridges the two notations.

1ED   ->  755      file mode rwxr-xr-x
1A4   ->  644      file mode rw-r--r--
81A4  ->  100644   st_mode of a regular file
1B    ->  33       ESC, written \033 in C strings
7F    ->  177      DEL, written \177
FF    ->  377      largest byte, \377

Input rules and output format

Type one hex number using the digits 0 to 9 and A to F in upper or lower case. An optional 0x prefix is removed and a leading minus sign is preserved, so -2d converts to -55. The box does not accept spaces between digits, a trailing h, or the 0o octal prefix, and it names the invalid character in its error message. The input may be up to 4,096 characters long.

The result contains only the digits 0 to 7 with no prefix and no leading zeros. Octal escape sequences in C take at most three digits, which is enough for one byte, since FF is 377. All of this is computed in the browser, with no server round trip.

Why digit counts differ

A hex number with n digits has up to 4n bits, and those need about 4n / 3 octal digits, rounded up. Two hex digits therefore become up to three octal digits, and eight hex digits become up to eleven: FFFFFFFF converts to 37777777777. The leading octal digit is often small, because the leftover one or two bits at the top form an incomplete group. That is why a byte in octal never starts with a digit above 3.

Frequently asked questions

What is 2D in octal?

2D is 55 in octal. In binary 2D is 101101, which splits into 101 and 101, and each group is the octal digit 5.

What is FF in octal?

FF is 377. The eight bits 11111111 regroup as 11, 111 and 111, giving the digits 3, 7 and 7.

Can I convert hex to octal digit by digit?

No. Hex digits hold four bits and octal digits hold three, so the boundaries do not line up. Go through binary or decimal instead, or let the tool convert the whole number at once.

Why would I need octal today?

Mainly for Unix file permissions, umask values and octal character escapes. Some older systems and avionics data buses also document values in octal. Hex is more common elsewhere because it aligns with bytes.

Does the tool add a leading zero to mark octal?

No. The output is the plain digits. Add the marker your language uses: a leading 0 in C and shell, or 0o in Python, JavaScript and Rust.

How do I convert octal back to hex?

Use the Octal to Hexadecimal tool. By hand, write each octal digit as three bits, regroup the bits in fours from the right and read each group as a hex digit: 755 is 111 101 101, or 1 1110 1101, which is 1ED.

Related tools