BinaryOctal

Spaces and 0b are fine

Try
Octal
755
Decimal 4933 octal digits · 9 bits

Digit by digit

Bits are grouped in 3s from the right
  1. 1117
  2. 1015
  3. 1015
Guide

How to convert binary to octal

  1. Remove spaces and any 0b prefix.
  2. Split the bits into groups of 3, starting from the right. If the leftmost group is short, pad it with zeros.
  3. Replace each group with its octal digit, from 0 to 7, using the table below.

Worked example

Converting 110100100 in groups of 3 from the right:

3 bitsOctal digit
1106
1004
1004

110100100 → 644

  • Group from the right, just like hex, so each group lines up with an octal place value.
  • The result 644 is a common Unix permission for files: the owner can read and write, everyone else can only read.
  • Add a 0o prefix to mark a number as octal in languages such as Python and JavaScript.

Octal digits in binary

3 bits per digit
OctalBinaryDecimal
00000
10011
20102
30113
OctalBinaryDecimal
41004
51015
61106
71117
Learn

Binary to octal conversion explained

Grouping bits in threes, padding, checking your answer and turning permissions into octal.

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:

PermissionsBinaryOctal
rwxr-xr-x111 101 101755
rw-r--r--110 100 100644
rwxr-x---111 101 000750
rw-------110 000 000600
rwxrwxrwx111 111 111777

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 0b prefix 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.

FAQ

Frequently asked questions

Quick answers about the binary to octal converter and how it works.

How do I convert binary to octal?

Split the bits into groups of 3 starting from the right, then replace each group with its octal digit. 110100100 becomes 110 100 100, which is 644.

What if the number of bits isn't a multiple of 3?

The leftmost group is padded with zeros, which doesn't change the value. 1010 becomes 001 010, which is 12.

How do I convert permissions like rwxr-xr-x to octal?

Write a 1 for each letter and a 0 for each dash: rwxr-xr-x is 111101101. Enter that here to get 755. rw-r--r-- is 110100100, or 644.

Why use octal instead of hex?

Hex groups bits in fours, which lines up with bytes, so it's more common in programming. Octal groups them in threes, which suits data that comes in 3-bit fields, like Unix permissions.

Can I add the 0o prefix?

Yes. Turn on Add 0o prefix to get a value like 0o644, the octal format used by Python and JavaScript.

What is 11111111 in octal?

377. Grouping from the right gives 11 111 111, and padding the left group makes it 011 111 111, or 3, 7, 7. That's 255 in decimal, the largest value a byte can hold. A byte's 8 bits don't divide into 3-bit groups evenly, which is one reason bytes are usually written in hex instead.

Still have a question?Contact us