Skip to content
AgileLogics

Octal to Hexadecimal

Converts a base-8 (octal) number into its base-16 (hexadecimal) equivalent.

How it works

Enter an octal number (e.g. 17) and click Convert.

How do you convert octal to hex?

Expand each octal digit into three bits, then regroup those bits in fours from the right and read off hex digits. Octal 1234 becomes 001 010 011 100, regrouped as 0010 1001 1100, which is 29c in hex. Binary is the bridge because both bases are powers of two: 8 is 2³ and 16 is 2⁴.

You can also go through decimal (multiply out by powers of 8, then divide by 16), but the bit route needs no arithmetic beyond two small lookup tables.

Using the converter

  1. Type the octal number. 0755 and 755 are equivalent.
  2. Click Convert.
  3. Copy the hex result, which comes out in lowercase with no 0x: 1ed.

Worked example: 1234

Stage Value
Octal digits 1 · 2 · 3 · 4
Each as 3 bits 001 · 010 · 011 · 100
Joined 001010011100
Regrouped in 4s from the right 0010 · 1001 · 1100
Hex digits 2 · 9 · c
Result 29c

To double-check, both sides equal 668 in decimal: 1 × 512 + 2 × 64 + 3 × 8 + 4 = 668, and 2 × 256 + 9 × 16 + 12 = 668.

Git file modes in hex

Git records every entry in a tree object with an octal mode. The git fast-import documentation lists the valid ones: 100644 for a normal file, 100755 for an executable, 120000 for a symlink, 160000 for a gitlink (submodule) and 040000 for a subdirectory. When you inspect packed objects, index files or other tools' binary output, those same values appear in hex:

Git mode (octal) Hex Entry type
100644 81a4 regular file
100755 81ed executable file
120000 a000 symbolic link
160000 e000 submodule (gitlink)
040000 4000 directory

Paste any of the octal modes into the tool to reproduce the right-hand column. The pattern is easy to see once you have it: the low 9 bits hold the permissions (644 is 1a4, 755 is 1ed) and the high bits hold the entry type.

Mistakes that cause errors

  1. Using 8 or 9. 789 is not octal. If you meant decimal, use the decimal to hex converter.
  2. Adding a prefix. 0o755 fails because o isn't a digit. A plain leading zero is fine.
  3. Spaces between digits. 7 5 5 fails. Outer whitespace is trimmed, inner whitespace isn't.
  4. Signs and points. -17 and 7.5 aren't supported; the tool converts non-negative whole numbers only.
  5. Values over 53 bits. Octal 400000000000000000 is 2^53, one past the safe limit, so it's refused instead of rounded.

Handy reference values

Octal Hex Note
7 7 single digits 0 to 7 are the same in both
10 8 octal 10 means eight
17 f fifteen
377 ff one full byte
777 1ff nine bits all set (rwxrwxrwx)
17777777777 7fffffff largest signed 32-bit integer

Doing it in a terminal or script

If you're already at a shell, printf '%x\n' 0755 prints 1ed. The leading zero matters there: the POSIX printf utility reads numeric arguments the way C reads integer constants, so 0755 is octal while 755 would be taken as decimal and print 2f3. In Python, write the octal literal explicitly and call hex(0o755), which returns '0x1ed'. The converter here avoids that ambiguity entirely, because it always reads your input as octal, with or without the leading zero.

Where to go next

The site doesn't have separate octal-to-decimal or octal-to-binary tools, but you can chain: convert here, then feed the hex into hex to decimal or hex to binary. For the reverse trip, hex to octal converts back, and decimal to octal is the place to start when your file mode was printed as a plain decimal number.

Last updated

Frequently asked questions

How do you convert octal to hex?
Write each octal digit as 3 bits, join them, then split the bits into groups of 4 from the right and write each group as a hex digit. 1234 becomes 001 010 011 100, regrouped as 0010 1001 1100, which is 29c.
Can I type octal with a leading zero, like 0755?
Yes. Leading zeros are accepted and ignored, so 0755 and 755 both give 1ed. A 0o prefix is not accepted, because the letter o isn't an octal digit.
Why do I get an error for 789?
Octal only uses the digits 0 to 7. An 8 or 9 means the number is decimal, not octal, and the tool shows "Enter a valid octal number". Use the decimal to hex converter instead.
How do I convert octal to decimal or binary on this site?
Convert to hex here first, then use Hex to Decimal or Hex to Binary on the result. Because the conversions are exact, chaining them gives the correct answer.
What's the largest octal number it handles?
377777777777777777 (eighteen digits), which is 1fffffffffffff in hex and 2^53 - 1 in decimal. Anything larger shows "That number is too large to convert precisely."