Decimal to Octal Converter – Free

Enter a base-10 whole number and this decimal to octal converter returns it in base 8, using the digits 0 to 7. Decimal 45 becomes 55.

How to use the Decimal to Octal tool

  1. Put the decimal value, such as 45 or a file mode like 493, in the Base-10 number box.
  2. Select Convert to produce the base-8 value.
  3. Read the octal digits in the Result box. No leading 0 or 0o prefix is added.
  4. Select Copy to take the octal digits to your clipboard, or Clear to empty the form.

How to convert decimal to octal

Octal has eight digits, 0 through 7, and each position is worth eight times the one to its right: 1, 8, 64, 512 and so on. To convert, divide the decimal number by 8 repeatedly. Each remainder is one octal digit, starting with the rightmost.

An octal digit corresponds to three bits, so 755 expands to 111 101 101 in binary.

493 / 8 = 61 remainder 5
 61 / 8 =  7 remainder 5
  7 / 8 =  0 remainder 7

493 = 755   (7 x 64 + 5 x 8 + 5)

Decimal to octal for Unix file permissions

The main reason developers still need octal is the Unix permission model. Each of owner, group and others gets three bits for read, write and execute, and three bits make one octal digit. APIs and logs often show the mode as a plain decimal integer, which hides the pattern.

The last two rows are st_mode values as returned by stat, where the upper digits encode the file type.

420    ->  644      rw-r--r--
493    ->  755      rwxr-xr-x
511    ->  777      rwxrwxrwx
33188  ->  100644   regular file, rw-r--r--
16877  ->  40755    directory, rwxr-xr-x

Input and output details

Type one whole number made of the digits 0 to 9. A leading minus sign is allowed and is kept in the result, so -45 converts to -55. Whitespace around the number is ignored. Decimal points, commas, inner spaces and a plus sign cause an error that names the character.

The output is the bare octal digits. Different languages mark octal differently: C and shell arithmetic use a leading 0, while Python, JavaScript, Rust and Swift use 0o. Add the prefix that your language expects. Input length is capped at 4,096 characters, and the arithmetic is exact at any size.

A common mistake with octal literals

A leading zero can silently change a number. In C, 0755 is octal and equals decimal 493. Calling chmod(path, 755) with the zero left off sets a very different mode, since decimal 755 is octal 1363.

Python 3 rejects 0755 as a syntax error and requires 0o755. JSON has no octal form at all, so configuration files usually carry modes as decimal numbers or as strings. Converting the decimal value here shows which permissions it really stands for.

Frequently asked questions

What is 45 in octal?

45 in octal is 55. Five eights are 40, and 5 is left over. Written with a prefix it is 055 in C or 0o55 in Python.

How do I convert 8 and 64 to octal?

8 is 10 in octal and 64 is 100. Powers of eight are a 1 followed by zeros, the same way powers of ten are in decimal.

Why is chmod 755 written in octal?

Each octal digit packs the three permission bits of one class of user. 7 is read, write and execute (111), 5 is read and execute (101). In decimal the same mode is 493, which says nothing at a glance.

Can octal digits include 8 or 9?

No. Base 8 uses only 0 to 7. If you see an 8 or 9, the number is not octal. The output of this converter never contains those digits.

Does this tool handle negative decimal numbers?

Yes. The minus sign is preserved and the magnitude is converted, so -255 becomes -377. It does not create a two's complement pattern, which would require a fixed word size.

How do I convert octal back to decimal?

Use the Octal to Decimal tool, or multiply each digit by its power of eight and add: 644 is 6 x 64 + 4 x 8 + 4 = 420.

Related tools