FormatterHQ

Decimal to Octal Converter

Convert decimal numbers to octal (base 8) instantly. Handy for Unix permission modes, octal escape codes and number-system exercises.

Loading tool…
Ready.

How to use the Decimal to Octal Converter

  1. Type a decimal number in the Decimal field.
  2. Read the octal result in the Octal field, which updates as you type.
  3. Copy the value, adding a 0o or leading 0 prefix if your language expects one.

Decimal to octal, explained with Unix permissions

This decimal to octal converter rewrites base-10 numbers using only the digits 0–7. Octal is less common than hex today, but it is still the native language of Unix file permissions and of octal escape sequences, so it pays to be able to move between the two quickly.

How octal works

Each octal position is worth eight times the one to its right: 1, 8, 64, 512, 4096. Since 8 = 2^3, one octal digit always stands for exactly three bits, which is what makes it so convenient for permissions.

Repeated division by 8

Divide by 8, keep the remainder, and repeat with the quotient. Read the remainders from last to first.

493 ÷ 8 = 61   remainder 5
 61 ÷ 8 = 7    remainder 5
  7 ÷ 8 = 0    remainder 7
493 = 755 in octal

Fractions use multiplication instead: 0.75 × 8 = 6, so 3.75 becomes 3.6. Repeating fractions are cut off after 20 octal places.

Example

Input    Output
10       12
255      377
420      644
493      755
33188    100644
3.75     3.6

Why you might have a permission in decimal

Many APIs report a file's mode as a plain integer. Python's os.stat() and Node's fs.statSync() give st_mode values such as 33188, and JSON has no octal literals at all. Converting 33188 gives 100644: the leading 100 marks a regular file and 644 is the permission part, read as rw-r--r--.

Likewise, 493 is 755 (rwxr-xr-x), the usual mode for executables and directories, and 420 is 644, the usual mode for ordinary files.

The classic chmod mistake

Passing permissions as a decimal number is one of the most common bugs in scripts. In Python, os.chmod(path, 755) looks right but 755 is read as decimal, and decimal 755 is octal 1363:

755 ÷ 8 = 94   remainder 3
 94 ÷ 8 = 11   remainder 6
 11 ÷ 8 = 1    remainder 3
  1 ÷ 8 = 0    remainder 1
755 (decimal) = 1363 (octal)  → sticky bit, -wx rw- -wx

The file ends up with the sticky bit set and nonsense permissions. Write 0o755 in Python and in Node's fs.chmodSync(), or the decimal 493 if an API only takes plain integers. The same trap exists when parsing: in JavaScript, parseInt('755', 8) returns 493, while parseInt('0755') returns 755 because a leading zero no longer means octal.

Other places octal appears

  • Escape sequences: in C, shells and many other languages, \033 is the escape character, decimal 27.
  • Number literals: Python 3 and modern JavaScript write octal as 0o755; C still uses a leading zero (0755).
  • Teaching: octal is a gentle introduction to bases before hexadecimal.

Tips

The result never carries a prefix, so add the one your language expects. Negative numbers keep a minus sign, and integers of any size convert exactly. To go back, use octal to decimal; to see all bases at once, open the all number converter. If you want to see the three bits behind each digit, decimal to binary shows the full bit pattern.

Frequently asked questions

What is 755 in decimal?
Octal 755 is 493 in decimal: 7 × 64 + 5 × 8 + 5. Converting 493 with this tool gives 755 back.
Why do Unix permissions use octal?
Each permission group (owner, group, others) has three bits: read, write and execute. Three bits fit exactly in one octal digit, so a mode such as rwxr-xr-x becomes the neat three-digit 755.
Does a leading zero matter in octal?
The value is the same, but many languages use the leading zero as a marker. In C, 0755 is octal while 755 is decimal, which is a common source of permission bugs.
Can I convert decimal fractions to octal?
Yes. The fractional part is converted by repeated multiplication by 8, so 3.75 gives 3.6. Fractions that repeat forever are shown to 20 octal places.

Last updated October 3, 2026

Related tools