Decimal to Octal

Convert decimal to octal (base 8) instantly, e.g. 493 to 755 for chmod permissions. Exact for large numbers, with thousands commas accepted.

Runs in your browser. Files never leave your device.
Whole numbers of any size. Negative numbers keep a minus sign (not two's complement); fractions aren't supported.
Result (Octal (base-8))
100

About the Decimal to Octal

Rewrite a base-10 whole number in base 8, the number system that uses only the digits 0 to 7. You'll need it most for Unix file permissions, though older computing manuals list values in base 8 too, and it's a quick way to check base 10 to base 8 homework step by step.

Type a number and the octal form appears at once, exact for any size you're likely to paste. A common case is a permission value that a script printed in decimal, such as 420, which this page turns back into the familiar 644.

How it works

Octal place values are powers of eight: 1, 8, 64, 512, 4096 and upwards. Converting from decimal means working out how many of each power fit, and the division method does that for you. Divide by 8, keep the remainder (0 to 7), divide the quotient by 8 again and stop when it reaches 0. The remainders, last one first, are the octal digits.

Since 8 is 2³, each octal digit maps to exactly three binary bits. That's why a three-digit octal number like 755 describes nine permission bits so neatly: one digit each for the owner, the group and everyone else.

repeat while n > 0:
  digit = n mod 8
  n     = floor(n ÷ 8)
octal = digits read from the last remainder to the first

check: value = dₖ×8ᵏ + … + d₁×8 + d₀

Assumptions and limits

  • The input must be a whole decimal number. Points, exponents and stray letters are refused with a short explanation.
  • Results carry no prefix. Python and JavaScript want 0o before the digits (0o755), C uses a leading 0 (0755), and the chmod command takes the bare digits (chmod 755).
  • A minus sign is carried over unchanged, so −8 becomes −10 in octal.
  • Leading zeros are dropped, so 8 shows as 10, not 010.
  • Very long inputs are capped at 4,096 decimal digits.

Worked examples

Decimal 2026 to octal

Four divisions by 8 leave the remainders 2, 5, 7 and 3. Reading them in reverse gives 3752.

2026 ÷ 8 = 253  r 2
 253 ÷ 8 =  31  r 5
  31 ÷ 8 =   3  r 7
   3 ÷ 8 =   0  r 3
→ 3752   (3×512 + 7×64 + 5×8 + 2 = 2026)

File permissions printed as a decimal number

A script that prints a file mode as an ordinary integer might show 493 or 420. Converting gives 755 (owner can read, write and run; others read and run) and 644 (owner reads and writes; others only read). 511 converts to 777, full access for everyone.

Using binary as a shortcut

For 100, write the binary 1100100, split it into threes from the right as 1 100 100, and read each group as a digit: 1, 4, 4. So 100 in decimal is 144 in octal.

Decimal to octal chart

Includes the permission values most often typed into chmod. Read the Octal column back to the Decimal column to convert the other way.

DecimalOctalComment
77largest single octal digit
810first two-digit value
911
1012
1620
641008²
100144
255377one full byte
256400
420644rw-r--r--
438666rw-rw-rw-
493755rwxr-xr-x
511777rwxrwxrwx
51210008³
10001750
4096100008⁴

How to use the Decimal to Octal

  1. Type the base-10 number. The box starts at 64; replace it with your value, commas for thousands allowed.
  2. See the octal answer. Digits 0 to 7 appear in the result panel immediately, or a message if something in the input isn't valid.
  3. Copy the octal digits. Use Copy Result, then add 0o or a leading 0 if your language or command needs one.

Frequently asked questions

What is 8 in octal?

10. Octal has no digit for eight, so after 7 it carries over to the next place, just as decimal goes from 9 to 10. In the same way 64 is 100 and 512 is 1000 in octal.

How do I turn a decimal permission number into chmod format?

Convert it to octal here and use the last three digits. 493 gives 755 and 420 gives 644. If the number includes file-type bits, such as 33188 for a regular file, the octal is 100644 and the final 644 is the permission.

Why is octal used for Unix permissions?

Each permission group has three bits: read, write and execute. Three bits hold values from 0 to 7, exactly one octal digit, so owner, group and others fit into three digits. Read is 4, write is 2 and execute is 1.

How can I check an octal answer?

Multiply each octal digit by its place value and add. For 755 that is 7 × 64 + 5 × 8 + 5 × 1 = 448 + 40 + 5 = 493, the number you started with. If a digit 8 or 9 ever appears in your answer, a step went wrong, because octal only uses 0 to 7.

Why does 010 mean 8 in some programming languages?

In C and older JavaScript, a leading zero marks a number as octal, so 010 is eight, not ten. Modern Python and JavaScript use 0o10 to avoid that confusion. This converter's output has no prefix at all.

This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.