Skip to content
AgileLogics

Binary to Octal

Converts a base-2 (binary) number into its base-8 (octal) equivalent.

How it works

Enter a binary number (e.g. 1010) and click Convert.

How do you convert binary to octal?

Break the binary number into groups of three bits, counting from the right, and replace each group with its value from 0 to 7. Octal is base 8, and 8 is 2 cubed, so three bits always make exactly one octal digit. 111101101 splits as 111 101 101 and becomes 755.

There's no multiplying or long division involved. You only need to know the eight 3-bit patterns, and the table below covers all of them.

Using this converter

  1. Enter the binary value, for example 110100100.
  2. Click Convert.
  3. Read off the octal result, here 644.

Input with leading zeros (000111) is accepted and gives 7. Whitespace before or after the number is trimmed, but spaces between groups are not allowed, so type 111101101 rather than 111 101 101.

The eight 3-bit patterns, read as permissions

Octal's best-known job is Unix file permissions, where each bit in a group switches one permission on. The bits are worth 4 (read), 2 (write) and 1 (execute), as defined for the numeric mode of chmod in POSIX:

Bits Octal Permission Meaning
000 0 --- no access
001 1 --x execute only
010 2 -w- write only
011 3 -wx write and execute
100 4 r-- read only
101 5 r-x read and execute
110 6 rw- read and write
111 7 rwx everything

So when ls -l shows rwxr-xr-x, write it as bits (111 101 101) and the octal mode drops straight out: 755.

Worked examples

A web server file. rw-r--r-- is 110 100 100. Paste 110100100 into the tool and you get 644, the usual mode for HTML and image files.

A private directory. rwx------ is 111 000 000. The tool gives 700.

A shared project folder. rwxrwxr-x is 111 111 101, which converts to 775.

A bit count that isn't a multiple of three. 11101101 has eight bits. Group from the right: 11 101 101. Pad the short group to 011, which is 3, so the answer is 355. If you grouped from the left you'd get 111 011 01, a different and wrong number. The tool parses the whole value, so it never makes that mistake.

Turning the result into a chmod command

  1. Write out the permission string for owner, group and others.
  2. Replace each letter with 1 and each dash with 0.
  3. Paste the nine bits into the converter.
  4. Use the three-digit result: chmod 644 index.html.

A fourth, leading octal digit sets the special bits (setuid 4, setgid 2, sticky 1). Twelve bits such as 111101101101 convert to 7555, which sets all three special bits on top of r-xr-xr-x, so check before you run something like that.

Limits and what it won't do

Situation What happens
More than 53 bits "That number is too large to convert precisely."
0b prefix, spaces, - or . "Enter a valid binary number..."
Empty box Output clears, no error
Leading zeros in the input Accepted and dropped from the output

The tool works on whole unsigned numbers only. It doesn't produce a permission string from octal or interpret rwx letters directly, so do the letter-to-bit step yourself as shown above.

Related tools

  • Decimal to octal helps when a script printed a file mode as a plain decimal number.
  • Octal to hexadecimal converts modes into the hex you see in a raw stat dump.
  • Binary to hex uses 4-bit groups instead, the standard for bytes and memory.
  • The Bash lessons cover changing file permissions with chmod in both symbolic and numeric form.

Last updated

Frequently asked questions

How do I convert binary to octal manually?
Split the bits into groups of three from the right, pad the leftmost group with zeros, and write each group as a digit from 0 to 7. 11101101 becomes 011 101 101, which is 355.
Why is octal used for Unix file permissions?
Permissions come in three sets of three bits (read, write, execute for owner, group and others). Three bits hold exactly one octal digit, so each set becomes one digit and rwxr-xr-x is simply 755.
What input does the converter accept?
A run of 0s and 1s with no spaces, no 0b prefix, no sign and no binary point. Leading zeros and surrounding whitespace are fine. Up to 53 bits are converted exactly; longer input shows "That number is too large to convert precisely."
Does the result include a leading 0 or 0o prefix?
No. 111101101 gives 755, not 0755 or 0o755. Add the prefix your language expects: 0o755 in Python and JavaScript, 0755 in C and in shell commands.