Decimal to Octal Converter

Enter a decimal number to get its octal form, with the repeated division by 8 worked out below.

Loading tool…

About the Decimal to Octal

To convert decimal to octal, divide by 8 repeatedly and write down the remainders (always 0–7). The remainders read from the last to the first are the octal digits. For 493: 493 ÷ 8 = 61 remainder 5, 61 ÷ 8 = 7 remainder 5, 7 ÷ 8 = 0 remainder 7, so 493 = 755 in octal. The table below the result repeats these steps for your input.

There is also a shortcut through binary: write the number in binary and group the bits in threes from the right, because 8 = 23. 493 is 111 101 101 in binary, and the groups read 7, 5, 5. That three-bit grouping is exactly why Unix permissions are written in octal — each digit holds the read, write and execute bits for one class of user.

When you use the result in code, add the right prefix: 0o755 in Python 3, JavaScript and Rust, 0755 in C, Go and shell chmod. Other places octal still appears include escape sequences such as \033 (the ESC character, decimal 27) in shell and C strings, and some older file formats such as tar headers. The converter uses BigInt, so very large values stay exact.

How to use it

  1. Type a whole decimal number.
  2. Read the octal result.
  3. Follow the divide-by-8 table to see how each digit is produced.
  4. Copy the result and add the prefix your language expects (0o or 0).

Frequently asked questions

How do you convert decimal to octal?
Divide by 8, record the remainder, repeat with the quotient until it is 0, and read the remainders in reverse. 100 → 12 r4 → 1 r4 → 0 r1, so 100 = 144 in octal.
What is 8 in octal?
10 — octal has no digit 8, so it carries over just like 10 in decimal.
What is 511 in octal?
777, which as a Unix permission gives everyone read, write and execute access.
How do I convert decimal to octal in code?
JavaScript: (493).toString(8). Python: oct(493) gives '0o755', or format(493, 'o'). C: printf("%o", n).

Related tools