Article — Binary to Octal Converter
Binary to Octal Conversion Explained
Binary to octal conversion turns a string of 0s and 1s into a base-8 representation, where each octal digit (0-7) corresponds to exactly three binary bits. The binary 111101101 becomes 755 — the same notation millions of Linux users type after chmod every day. The rule is mechanical because 2³ equals 8.
Octal is less common than hex in modern code, but it has a permanent home in Unix file permissions and a handful of legacy systems. Once you know the 8-row triplet table, conversion is a glance.
What is binary to octal conversion?
Binary to octal is a base change, not an arithmetic operation. The numeric value is preserved across the conversion: 214 in decimal, 11010110 in binary, 326 in octal. Each octal place is worth eight times the place to its right. The digit set runs 0 through 7 — there is no 8 or 9 in octal, just as there is no A in decimal.
Octal sat between binary and decimal on early computers because the 12-bit, 24-bit, and 36-bit word sizes of machines like the PDP-8 divided cleanly into 3-bit groups. The IBM/360 standardized on 8-bit bytes and 32-bit words, which divide into 4-bit nibbles, and hex displaced octal in most contexts.
Charles XII of Sweden proposed using octal in 1717, almost three centuries before computing. Emanuel Swedenborg argued for base 8 as a human counting system around the same time. Both were ignored — decimal won at the human level, and the computer-age octal revival had nothing to do with these earlier proposals.
The 3-bit grouping method
The algorithm is straightforward. Take the binary number, split into 3-bit groups starting from the right, pad the leftmost group with zeros if it is short, then convert each group to its octal digit. The technical name for a 3-bit group is a triplet — there is no standard term equivalent to nibble.
Take 110101110. Split from the right: 110, 101, 110. Convert each: 110 = 6, 101 = 5, 110 = 6. The answer is 656 octal. A few of the most useful triplet-to-digit mappings are worth memorizing because they cover most cases.
111 = 7 110 = 6101 = 5 100 = 4011 = 3 010 = 2001 = 1 000 = 0Octal to binary the reverse way
Reverse conversion is even faster. Each octal digit expands to exactly three binary bits. Write them in order, strip leading zeros from the final result, and you are done. The octal 755 expands to 111 101 101. Concatenated and trimmed: 111101101.
Note the leading-zero rule: pad each digit to three bits during expansion. Octal 5 is 101, not just 11. Without the leading zero you misalign the next digit when concatenating.
Why octal still matters in Unix
The killer app for octal in 2026 remains chmod. Linux, macOS, BSD, and every other Unix-like system encodes file permissions as three octal digits — one for the owner, one for the group, one for everyone else. Each digit packs three permission bits: read (weight 4), write (weight 2), execute (weight 1).
chmod 755 means the owner has read + write + execute (4 + 2 + 1 = 7) and everyone else has read + execute (4 + 1 = 5). The same value in binary is 111 101 101 — exactly nine bits, three groups of three. This is the entire reason octal survives: file permissions are nine bits, and three octal digits express nine bits compactly.
The C function umask() also takes its argument in octal: umask(022) clears the group and other write bits from new files. The leading 0 is the C signal that a number literal is octal. In modern Python you must write 0o022 instead, because Python 3 dropped the C-style leading-zero convention.
Binary, octal, and hex compared
Hex (base 16) and octal (base 8) both exist for the same reason: condensing binary into a shorter human-readable form. The difference is the group size. Octal uses 3 bits per digit, hex uses 4. For a byte (8 bits), hex gives you two clean digits; octal gives three digits where the leftmost has only two significant bits.
- One byte = 8 binary bits = 2 hex digits = 3 octal digits (top digit max 3)
- One word (32-bit) = 32 bits = 8 hex digits = 11 octal digits
- chmod = 9 bits = 3 octal digits cleanly (no padding needed)
- Hex prefix = 0x (C), # (CSS), $ (Pascal)
- Octal prefix = leading 0 (C), 0o (Python 3, JS), 0o or @ (Forth)
- Max digit: octal 7, hex F, decimal 9
chmod octal cheat sheet
Web servers and shared filesystems use a small set of canonical chmod values. Memorize these and you cover most real-world permission decisions.
SSH private keys must be chmod 600 (rw-------) or the SSH client refuses to use them. Public web files should be 644 for files and 755 for directories. SUID/SGID files are 4xxx or 2xxx — the leading digit is a fourth octal digit for special bits.
Common binary-to-octal mistakes
The classic error is grouping from the left. Always start from the right and pad the leftmost group with zeros. The number 1010 has four bits, so pad to six: 001 010, giving 12 octal — not 10 octal (which would be 8 decimal, totally wrong).
In C and many older languages, 0755 is octal 755 (decimal 493), but 755 without the leading zero is decimal 755. Forgetting the leading 0 silently changes the permission you set. Modern languages either banned this (Python 3) or require explicit 0o prefix.
The second mistake is confusing octal with hex. The number 70 in octal is 56 in decimal; the same digits 70 in hex are 112 in decimal. Always confirm the base before interpreting a digit string.
Octal prefixes in code (0, 0o)
The leading-zero convention dates back to 1972 K&R C. It worked when programmers were careful, but it produced a famous category of bugs where adding a leading zero for visual alignment accidentally re-interpreted a constant. Python 3 fixed this by requiring 0o755 instead of 0755. JavaScript followed in ES6, and Rust uses 0o too.
This converter strips any leading 0 or 0o prefix automatically when you paste an octal value. Same for spaces, commas, and underscores in either direction.