An octal to binary converter expands base-8 numbers into binary, three bits for every octal digit. Type an octal number above, such as a Unix file permission like 755, and you'll see each digit beside the three bits it stands for. Below, you'll learn what octal is, how to convert octal to binary by hand, and how those bits describe who can read, write and run a file.
What is octal?
Octal is base 8. It uses only the digits 0 to 7, and each position is worth eight times the one to its right: 1, 8, 64, 512 and so on. So the octal number 17 means 1 × 8 + 7 = 15 in decimal. Octal was common on early computers whose word sizes were multiples of three bits, such as 12-bit and 36-bit machines, because their bits divided neatly into three-bit groups. Hexadecimal later became more popular for byte-based computers, but octal is still widely used for Unix permissions and in some programming contexts.
Why every octal digit is three bits
Eight is 2³, so three bits can hold exactly eight values, from 000 to 111. Every octal digit therefore matches one group of three bits. To convert octal to binary, you don't need to work out the value of the whole number. Just replace each digit with its three-bit pattern:
| Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Binary | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
Converting octal to binary by hand
Take 1777. The digit 1 is 001 and each 7 is 111, so the full result is 001 111 111 111. Dropping the two leading zeros gives 1111111111, ten ones in a row, which is 1,023 in decimal. You can check it: 1 × 512 + 7 × 64 + 7 × 8 + 7 = 1,023. This octal to binary converter keeps all three bits per digit by default so the groups stay lined up, and the Drop leading zeros switch removes the extra zeros at the front.
Octal and Unix file permissions
On Linux, macOS and other Unix-like systems, each file has three sets of permissions: for its owner, its group and everyone else. Each set has three switches, read, write and execute, which fit exactly into one octal digit. Read is worth 4, write 2 and execute 1, so in binary the three bits of each digit are r, w and x in that order. The chmod calculator works out any mode from checkboxes and gives you the command to run.
755is111 101 101, orrwxr-xr-x: the owner can do everything, and others can read and run the file.644is110 100 100, orrw-r--r--: the owner can read and write, and others can only read. It's the usual setting for ordinary files.600is110 000 000, orrw-------: only the owner can read or write. It's common for private keys.
A fourth leading digit sets special flags: 4 for setuid, 2 for setgid and 1 for the sticky bit. Shared temporary directories such as /tmp usually have the mode 1777, which is the sticky bit plus full permissions for everyone. To turn a permission string back into octal, use the binary to octal converter.
Octal in programming languages
Many languages mark octal numbers so they aren't confused with decimal. Python 3, JavaScript and Rust use a 0o prefix, as in 0o755. C, C++ and older code treat any number with a leading zero as octal, so in C, 010 equals 8, not 10, a classic source of bugs. This converter accepts the 0o prefix. A C-style leading zero is simply treated as another octal digit, which adds three zero bits at the front without changing the value.
Octal, binary and hex compared
Octal and hex are both shortcuts for binary. Octal groups bits in threes and hex groups them in fours. Hex fits bytes perfectly, since a byte is exactly two hex digits, which is why it's more common in modern programming. Octal fits data made of three-bit fields, like permissions, much better. If you need the same bits in hex, use the binary to hex converter on the result, or the hex to binary converter to compare.
Quick tips
- Only the digits 0 to 7 are valid. An 8 or 9 means the number isn't octal.
- Spaces and underscores are ignored, so long numbers can be grouped as you like.
- Turn off Space between groups to get one continuous string of bits.
- For the decimal value, check the result line above or use the binary to decimal converter.
For permissions, read each digit as three switches: 4 for read, 2 for write and 1 for execute. The chmod calculator turns any combination into the command to run.