Decimal to Octal

Encoders & Decoders

How to use the Decimal to Octal

Convert decimal to octal in two steps:

1

Enter the decimal number

Type or paste any positive integer using digits 0–9. The result updates instantly.

2

Read and copy the octal result

The octal value is shown with the 0o prefix (e.g. 0o755 for decimal 493). The panel below shows the equivalent binary and hex representations.


When to use this tool

Use to create octal values for Unix permissions and legacy code:

  • Computing the correct chmod octal permission value from a decimal value when setting Unix/Linux file permissions
  • Converting decimal integer values to octal for use as octal literals in Python 3 (0o...), JavaScript (0o...), or C code
  • Creating octal escape sequences for C or Python strings (e.g. \377 for decimal 255 = the DEL character byte)
  • Translating decimal umask values to their octal representation for shell scripts and system configuration
  • Understanding the octal representation of decimal values when reading legacy PDP-11 or VAX documentation
  • Building octal permission values programmatically when writing shell scripts that use chmod with numeric arguments

Frequently asked questions

Q:How does decimal to octal conversion work?
The algorithm repeatedly divides the decimal number by 8, collecting remainders (always 0–7) as octal digits. Reading the remainders in reverse order gives the octal representation. Example: 255 ÷ 8 = 31 R 7; 31 ÷ 8 = 3 R 7; 3 ÷ 8 = 0 R 3 — reading upward: 377. So decimal 255 = octal 0o377 = binary 11111111. The tool uses JavaScript BigInt to handle numbers of any size exactly.
Q:What octal value do I need for Unix permission 755?
For chmod 755 you need the octal number 755 — which is already in octal notation. The three digits represent owner (7 = rwx), group (5 = r-x), and others (5 = r-x). To get the decimal equivalent: 7×64 + 5×8 + 5×1 = 448 + 40 + 5 = 493. So chmod 755 is the same as chmod with decimal 493. If you have a decimal value and need to know the corresponding chmod permission, this tool converts it to octal for you.
Q:What is the 0o prefix and when should I use it?
The 0o prefix is the standard modern notation for octal literals in Python 3, JavaScript ES6+, and C23. In Python 3, you write 0o755 to create the integer 493. In JavaScript, const mode = 0o755 creates the number 493. In older code you may see a bare leading zero (0755 in C) — this is also octal but is being phased out because it looks like a decimal number. Always use 0o in modern code for clarity.
Q:How do I calculate a umask value in octal?
A umask value defines which permission bits to mask off (clear) when creating new files. The default umask 022 in octal means: owner — no bits cleared (0), group — write bit cleared (2), others — write bit cleared (2). In binary: 000 010 010. To calculate the effective permissions for a file created with mode 666: subtract the umask — 666 - 022 = 644 (rw-r--r--). Or more precisely, apply a bitwise NOT of the umask to the mode: 0o666 & ~0o022 = 0o644.
Q:Why does Python use 0o for octal instead of a leading zero?
Python 2 used a leading zero for octal literals (0755 = 493), which caused frequent confusion because developers would write 0100 intending decimal 100 but actually getting octal 100 = decimal 64. Python 3 changed to the unambiguous 0o prefix so that 0o755 is clearly octal and 755 is clearly decimal. JavaScript, Rust, and modern C also use the 0o prefix for the same reason. If you see a leading-zero integer literal in old code, it is almost certainly octal.
Q:What is decimal 8 in octal and why is it significant?
Decimal 8 = octal 0o10. This is significant because it reveals the base-change boundary: octal 0o7 = decimal 7, but octal 0o10 = decimal 8 (not decimal 10). Decimal 10 = octal 0o12. This mirrors how decimal 10 = binary 0b1010, not binary 10. Understanding these boundaries helps when mentally converting between bases: octal 10 = 1 group of 8, octal 100 = 1 group of 64 (8²), octal 1000 = 512 (8³).