Octal to Hexadecimal Converter – Free

This octal to hex converter turns a base-8 whole number into base 16. The answer is printed in uppercase digits without a 0x prefix.

How to use the Octal to Hexadecimal tool

  1. Paste the octal number into the Base-8 number box. A value such as 755 or 0o755 works.
  2. Select Convert. The Example button fills in 55 and converts it for you.
  3. Read the hexadecimal digits in the Result box.
  4. Select Copy to copy the hex value, or Clear to begin again.

How octal to hex conversion works

Octal and hexadecimal are both shorthand for binary. An octal digit stands for three bits and a hex digit for four. The digits do not line up with each other, so the usual hand method goes through binary: expand each octal digit to three bits, regroup the bits in fours starting from the right, then name each group as a hex digit.

The converter does the equivalent with integer math. It parses the base-8 digits into a big integer and writes that integer in base 16, using the letters A to F in uppercase.

Worked example: 755 to 1ED

Take octal 755. Its digits expand to 111, 101 and 101, giving the bit string 111101101. Split from the right into groups of four: 1, 1110 and 1101. Those are the hex digits 1, E and D.

755     →  111 101 101  →  1 1110 1101  →  1ED
55      →  2D
377     →  FF
100644  →  81A4

Where octal meets hex in practice

Older Unix interfaces and documentation favor octal, while modern debuggers, hex editors and protocol specs favor hexadecimal. Converting between the two comes up whenever you compare them.

  • Escape sequences. The terminal escape character is \033 in octal and \x1B in hex.
  • File type flags in Unix headers. S_IFREG is 0100000 in octal, which is 0x8000, and S_IFDIR is 040000, or 0x4000.
  • Dump tools. The od command prints octal by default, while xxd and most debuggers print hex.
  • Git tree entries, where a regular file has mode 100644. In hex that is 81A4.

Accepted input and output format

Enter one whole number with digits 0 to 7. A leading minus sign is allowed and carries through to the result, so -17 gives -F. A 0o prefix is stripped, and leading zeros are harmless. The number can be up to 4,096 characters long.

The result has no 0x prefix and no padding, so add those yourself if your code needs them. Inputs containing 8, 9, hex letters, spaces or a decimal point are rejected with an Invalid base-8 digit message.

Frequently asked questions

What is octal 377 in hexadecimal?

It is FF, or 255 in decimal. Octal 377 is 011 111 111 in binary, and the eight significant bits are all ones, which is the largest value of one byte.

Why can't I map octal digits to hex digits one by one?

Because the digit sizes differ. Three bits per octal digit and four bits per hex digit only align every 12 bits, so four octal digits correspond to three hex digits. Regrouping through binary handles the mismatch.

Is the hex output uppercase or lowercase?

Uppercase. The letters A through F are always capitals and there is no 0x prefix. Hex parsers in most languages accept either case, so the output can be pasted into source code after adding the prefix.

Does the converter keep leading zeros?

No. The value is treated as a number, so 0017 converts to F. If you need a fixed number of hex digits, pad the result on the left with zeros.

How large a number can I convert?

Up to 4,096 characters of input. The arithmetic uses big integers, so a number far beyond 64 bits still converts exactly. As a smaller check, octal 37777777777 returns FFFFFFFF, the largest 32-bit value.

Related tools