FormatterHQ

Hexadecimal to Octal Converter

Convert hexadecimal numbers straight to octal. Useful for turning file modes from hex dumps into chmod values, and for number-system practice.

Loading tool…
Ready.

How to use the Hexadecimal to Octal Converter

  1. Type or paste a hexadecimal number in the Hexadecimal field, with or without a 0x prefix.
  2. Read the octal value in the Octal field, which updates as you type.
  3. Copy the result into your notes, script or answer.

Hex to octal conversion

This hex to octal converter changes base-16 numbers into base 8. Both bases are powers of two, yet their digits do not line up (hex digits cover 4 bits, octal digits cover 3), so the clean way to convert is to go through binary.

The binary bridge

  1. Expand each hex digit into four bits.
  2. Regroup the bits into threes, starting from the right.
  3. Replace each 3-bit group with an octal digit.
1ED
→ 0001 1110 1101          (hex digits as 4 bits)
→ 000 111 101 101         (regrouped in threes)
→   0   7   5   5  = 755

The same result via decimal takes more work: 1ED is 493, and 493 divided repeatedly by 8 also gives 755. The binary route avoids division entirely.

Example

Input        Output
A            12
FF           377
1F4          764
1ED          755
7FFFFFFF     17777777777
A.8          12.4

Fractions regroup from the point outward. A.8 is 1010.1 in binary, which becomes 001 010 . 100, or 12.4 in octal.

A practical case: file modes

Tools that dump raw structures, such as hex editors or debuggers, may show a file's st_mode in hexadecimal. The value 81A4 converts to 100644: a regular file with permissions 644 (rw-r--r--). 81ED gives 100755, an executable file with rwxr-xr-x. Git uses these same numbers, 100644 and 100755, for file modes in its trees.

Input rules

  • 0x and # prefixes are removed, and letters can be upper or lower case.
  • Spaces, commas and underscores are ignored, and the field holds one number at a time.
  • Integers of any length convert exactly; fractions stop after 20 octal places.

Common mistakes

  • Dropping zeros inside the number. Every hex digit except the first must expand to a full four bits. F2 is 1111 0010; writing the 2 as just 10 gives 111110 and the wrong answer 76 instead of 362.
  • Regrouping from the left. The eight bits of FF grouped from the left (111 111 11) do not make sense; grouped from the right (11 111 111) they give 377.
  • Reading the result as decimal. Octal 377 is 255, not three hundred seventy-seven.

To go the other way, use octal to hex. The intermediate steps are easy to check yourself with hex to binary and binary to octal.

Writing the result in code

Octal literals are spelled differently from language to language, and a wrong prefix silently changes the value:

Where755 octal written as
C, C++, Go (classic form)0755
Python 3, JavaScript, Rust, Go0o755
chmod, umask755 (always read as octal)

In JavaScript, a leading zero such as 0755 is a legacy form that is a syntax error in strict mode, and Python 3 rejects it entirely. In a shell you can check a single value without any tool: printf '%o\n' 0x1ED prints 755. For values longer than 64 bits, or with a fractional part, the converter above is the easier route.

Frequently asked questions

Why can't I convert hex to octal digit by digit?
One hex digit holds 4 bits and one octal digit holds 3, so their boundaries only line up every 12 bits. Going through binary, or through decimal, handles the mismatch.
What is 0xFF in octal?
0xFF is 377 in octal. In binary it is 11111111, which regroups as 011 111 111.
Does the converter keep leading zeros?
No. The output uses the fewest digits needed, so a padded input like 00FF still gives 377. Add leading zeros yourself if a format requires a fixed width.
Can I convert negative hex numbers?
Yes, a leading minus sign is kept: -FF becomes -377. Two's complement bit patterns are treated as ordinary positive numbers.

Last updated October 3, 2026

Related tools