OctalBinary

Digits 0–7, with or without 0o

Try
Binary
111 101 101
Decimal 4933 octal digits · 9 bits

Digit by digit

Each octal digit is exactly 3 bits
  1. 7111
  2. 5101
  3. 5101
Guide

How to convert octal to binary

  1. Remove the 0o prefix if there is one.
  2. Replace each octal digit with its 3 bits from the table below. 7 is 111 and 5 is 101.
  3. Write the groups side by side in the same order. Drop leading zeros unless you need a fixed width.

Worked example

Converting the file permission 755, digit by digit:

Octal digit3 bitsPermission
7111rwx (owner)
5101r-x (group)
5101r-x (others)

755 → 111 101 101

  • Every octal digit is exactly 3 bits, so 3 octal digits make 9 bits.
  • Octal digits only go up to 7. An 8 or a 9 means the number isn't octal.
  • Unix file permissions are octal. Each digit's three bits mean read, write and execute.

Octal digits in binary

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

Octal to binary conversion explained

What octal is, how each digit becomes three bits, and how it describes file permissions.

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:

Octal01234567
Binary000001010011100101110111

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.

  • 755 is 111 101 101, or rwxr-xr-x: the owner can do everything, and others can read and run the file.
  • 644 is 110 100 100, or rw-r--r--: the owner can read and write, and others can only read. It's the usual setting for ordinary files.
  • 600 is 110 000 000, or rw-------: 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.

FAQ

Frequently asked questions

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

How do I convert octal to binary?

Replace each octal digit with its 3-bit pattern and keep them in the same order. 755 becomes 111 101 101.

Why is each octal digit exactly 3 bits?

Octal has 8 digits, and 8 is 2³, so every octal digit matches one group of 3 bits exactly.

Which digits are allowed?

Only 0 to 7. An 8 or a 9 means the number isn't octal, and the tool shows an error.

What is octal used for?

Most often for Unix file permissions. Each digit's three bits mean read, write and execute, for the owner, the group and everyone else. 755 is rwxr-xr-x.

Can I include a 0o prefix or a leading zero?

Yes. A leading 0o is removed. A C-style leading zero, as in 0755, is just another digit and adds three zero bits at the front. Turn on Drop leading zeros to remove them.

What is 777 in binary?

111 111 111: each 7 becomes 111, so all nine bits are 1. As a file permission that's rwxrwxrwx, full access for everyone, and in decimal it's 511.

Still have a question?Contact us