Unix permissions and some older systems still use base 8, and a binary to octal converter gets there by reading the bits three at a time. Paste a binary number above and you'll see its octal value immediately, along with every three-bit group and the digit it produced. This guide shows how to convert binary to octal by hand, how to check the result, and how to turn Unix permission strings like rwxr-xr-x into the numbers used by chmod.
How to convert binary to octal
Start at the right-hand end of the binary number and split it into groups of three bits. If the leftmost group is short, pad it with zeros on the left. Then replace each group with its octal digit, from 000 = 0 to 111 = 7. Take 1011101. Grouping from the right gives 1 011 101, and padding the first group gives 001 011 101. Those groups are 1, 3 and 5, so the answer is 135.
Why the groups start on the right
Octal place values are powers of 8: 1, 8, 64, 512 and so on. Each one corresponds to exactly three binary places, starting from the ones place on the right. Grouping from the right keeps every group aligned with an octal place. Grouping from the left only gives the right answer when the number of bits is a multiple of three. The zeros added to the first group never change the value, which is why this binary to octal converter shows them in a lighter style in the digit-by-digit view.
Checking your answer
To check a conversion, compare both numbers in decimal. 1011101 is 64 + 16 + 8 + 4 + 1 = 93. The octal number 135 is 1 × 64 + 3 × 8 + 5 = 93. They match, so the conversion is correct. The decimal value of every result appears under the converter, and the binary to decimal converter shows the full place-value breakdown if you need it.
Turning permissions into octal
Unix file permissions are written as nine letters, such as rwxr-xr-x, in three sets: owner, group and everyone else. Each set fits into one octal digit. Write a 1 for each letter and a 0 for each dash, then convert the bits:
| Permissions | Binary | Octal |
|---|---|---|
| rwxr-xr-x | 111 101 101 | 755 |
| rw-r--r-- | 110 100 100 | 644 |
| rwxr-x--- | 111 101 000 | 750 |
| rw------- | 110 000 000 | 600 |
| rwxrwxrwx | 111 111 111 | 777 |
The octal result is what you pass to commands such as chmod 755 script.sh. Because read is worth 4, write 2 and execute 1, you can also add the values directly: rw- is 4 + 2 = 6. To go the other way and see the bits behind a mode, use the octal to binary converter.
Binary to octal or binary to hex?
Both octal and hexadecimal are shorthands for binary, and both are converted by grouping bits. Octal uses groups of three and hex uses groups of four. Hex lines up with bytes, since one byte is exactly two hex digits, so it's the usual choice for memory, colors and machine code. Octal is the better fit when data comes in three-bit fields, such as permissions, or when you're working with systems and documentation that use it. For hex, try the binary to hex converter.
Patterns worth recognizing
A few groups appear often enough that you'll soon know them on sight. 111 is 7, the largest octal digit, so a string of ones always becomes a string of 7s: 111111111 is 777. 100 is 4 and 010 is 2, the read and write bits. A binary number of n groups is always less than 8ⁿ, so nine bits, three groups, can never be larger than 777, which is 511.
Octal notation
When you use the result in code, mark it as octal so it isn't read as decimal. Python 3, JavaScript and Rust use a 0o prefix, as in 0o644. C and C++ treat a number with a leading zero as octal, so 0644 is octal there, while 644 on its own is decimal. Turn on Add 0o prefix to get a value that's ready to paste.
Things to watch for
- Spaces, underscores and a
0bprefix are ignored, so you can paste binary in any common format. - A binary number with a minus sign keeps the sign in the octal result.
- Leading zeros in the result are dropped, because they don't change the value.
- Everything runs in your browser, with no limit on how many conversions you make.
Check an answer by converting it back: each octal digit should expand to exactly the three bits it came from, including any padding zeros at the front.