About the Octal to Decimal
Enter a base-8 number, written with the digits 0 to 7, and its ordinary base-10 value appears as you type. Reach for it when a script, a C string, a config file or a textbook hands you octal and you need the plain number: file modes such as 755, escape codes such as \033, or base 8 to 10 exercises.
The answer is exact for numbers of any practical length, because the digits are added up with whole-number arithmetic that never rounds. If you paste something that isn't octal, for example a value containing an 8 or a 9, the page names the digit that's wrong instead of guessing.
How it works
In octal every place is worth eight times the place to its right. Reading from the right, the first place counts ones, the second eights, the third sixty-fours, and the next ones 512s, 4,096s and 32,768s. To get the decimal value, multiply each digit by the worth of its place and add the results.
The converter works through the same sum in a quicker order, left to right: start at zero, and for each digit multiply the running total by 8 and add the digit. Both routes give the same answer. The total is kept as a BigInt, so a 40-digit octal number comes out with every decimal digit correct.
decimal = dₖ×8ᵏ + … + d₂×64 + d₁×8 + d₀ d₀ is the rightmost digit, each d is 0 to 7. Left-to-right shortcut: total = total × 8 + next digit
Going the other way is a matter of repeated division by 8; the Decimal to Octal page shows that method.
Assumptions and limits
- Only the digits 0 to 7 are valid. An 8 or a 9 stops the conversion with a message such as "8" isn't an octal digit, which usually means a decimal number was pasted by mistake.
- A 0o prefix (as in Python's 0o755) is accepted and ignored, and so are leading zeros, so 0755, 0o755 and 755 all give 493.
- Spaces or underscores between digit groups are allowed one at a time, so 1 777 and 1_777 both read as 1777.
- Fractions such as 0.4 are refused; the converter handles whole numbers only. A minus sign is kept as a sign, so −17 becomes −15.
- The decimal answer is printed without thousands separators, and input is limited to 4,096 digits.
Worked examples
Octal 3657 to decimal by place value
Write the worth of each place under the digits, multiply, and add. The left-to-right shortcut reaches the same number: 3, then 3×8+6 = 30, then 30×8+5 = 245, then 245×8+7 = 1967.
3 × 512 = 1536 6 × 64 = 384 5 × 8 = 40 7 × 1 = 7 3657₈ = 1967₁₀
Reading an octal escape code
C, shell printf and many terminal scripts write special characters as a backslash followed by three octal digits. \033 is 3×8+3 = 27, the Escape character that starts colour codes such as \033[1m. \101 is 64+1 = 65, the code for the letter A, and \012 is 10, a line feed.
Writing a file mode in a JSON setting
JSON has no way to write an octal number, so when a program reads a permission from JSON it has to be the decimal value. Convert here first: 644 becomes 420 and 755 becomes 493. Typing 644 directly would set a very different mode.
Octal to decimal chart
Read left to right for octal to decimal, right to left for decimal to octal.
| Octal | Decimal | Where it turns up |
|---|---|---|
| 7 | 7 | largest single digit |
| 10 | 8 | first carry |
| 12 | 10 | line feed (\012) |
| 15 | 13 | carriage return (\015) |
| 17 | 15 | the sample value on this page |
| 20 | 16 | |
| 33 | 27 | Escape (\033) |
| 40 | 32 | space character |
| 60 | 48 | the digit 0 in ASCII |
| 77 | 63 | largest two-digit value |
| 100 | 64 | 8² |
| 101 | 65 | letter A |
| 141 | 97 | letter a |
| 177 | 127 | Delete, top of 7-bit ASCII |
| 377 | 255 | largest byte |
| 644 | 420 | rw-r--r-- |
| 755 | 493 | rwxr-xr-x |
| 777 | 511 | rwxrwxrwx |
| 1000 | 512 | 8³ |
| 7777 | 4095 | largest four-digit value |
| 10000 | 4096 | 8⁴ |
How to use the Octal to Decimal
- Enter the octal number. Replace the sample 17 with your digits; a 0o prefix or leading zero can stay.
- Read the decimal value. The base-10 result updates with every keystroke, or a note points to the digit that isn't 0 to 7.
- Copy the result. Press Copy Result to paste the decimal number into your code, form or worksheet.
Frequently asked questions
What is 777 in octal as a decimal number?
511. The three digits are worth 7×64 + 7×8 + 7 = 448 + 56 + 7. It is one less than 1000 in octal, which is 512, in the same way that 999 is one less than a thousand in decimal.
How do I convert octal to decimal by hand?
Number the digits from the right starting at 0, multiply each digit by 8 raised to its position, and add everything up. For 52: 5×8 + 2×1 = 42. For longer numbers, multiplying the running total by 8 before adding each digit saves effort.
Why does the converter say my number isn't octal?
Octal only has the digits 0 to 7, so any 8 or 9 means the value was written in another base, most often plain decimal. Letters are refused too; a number with A to F in it is probably hexadecimal.
Does 0755 give a different answer from 755?
No. 0755, 0o755 and 755 all come out as 493. A leading zero adds nothing to the value; in C code and shell commands it is only the signal that the digits are octal, and Python uses the 0o prefix for the same job. The converter accepts all three spellings.
How does octal relate to binary?
Eight is two cubed, so every octal digit stands for exactly three bits: 5 is 101, 7 is 111. Octal 57 is therefore binary 101 111, which is 47 in decimal. That is why octal was popular on early computers with 12-bit and 36-bit words.
Can I convert an octal fraction like 0.4?
Not with this tool, which accepts whole numbers only. By hand, the first digit after the point is worth eighths, the next sixty-fourths, so 0.4 in octal is 4/8 = 0.5 and 0.04 is 4/64 = 0.0625.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.