Converters

Binary to Octal Conversion: Complete Guide with Table, Examples & Code

Learn how to convert binary to octal using the 3-bit grouping method. Includes a complete conversion table (0-255), step-by-step examples, Python/JavaScript/C code, and practical applications in Unix file permissions.

Published March 19, 2026
11 minute read
Cryptography Guide

Binary to Octal Conversion: Complete Guide with Table, Examples & Code

Binary-to-octal conversion is one of the cleanest operations in number system arithmetic. Because octal is base-8 and 8 is an exact power of 2 (2³ = 8), every single octal digit maps to exactly three binary bits. No rounding, no remainders, no messy long division -- just a direct, mechanical substitution. This relationship made octal a favorite notation in early computing, and it remains essential today for anyone working with Unix/Linux file permissions, legacy codebases, or embedded systems.

This guide covers the complete theory and practice of binary-to-octal conversion. You will learn why the conversion works, how to perform it by hand, how to handle edge cases like odd-length binary strings, and how to write code that does it for you. Try our free binary to octal converter to follow along with any of the examples below.

Number Systems Overview

Before diving into the conversion itself, it helps to understand the four number systems that programmers encounter most often.

Binary (Base-2)

Binary uses only two symbols: 0 and 1. Every digital computer is built on binary logic because transistors operate in two states -- on and off. While binary is the native language of hardware, it is verbose for humans: the decimal number 255 requires eight binary digits (11111111).

Octal (Base-8)

Octal uses eight symbols: 0 through 7. Each octal digit represents exactly three binary bits, making it a compact shorthand for binary data. Octal was especially popular on systems with 12-bit, 24-bit, and 36-bit word lengths, where the word size divides evenly by three.

Decimal (Base-10)

Decimal uses ten symbols: 0 through 9. It is the system humans grow up with and use in everyday life. However, decimal does not align neatly with binary -- there is no whole number n such that 10 = 2^n -- which makes decimal-to-binary conversion require repeated division.

Hexadecimal (Base-16)

Hexadecimal uses sixteen symbols: 0-9 and A-F. Each hex digit maps to exactly four binary bits (since 16 = 2^4). Hex dominates modern computing for memory addresses, color codes, and byte-level data inspection. For hex-to-binary conversion, see our hex to binary guide.

The key insight behind binary-to-octal conversion is a simple mathematical fact: 8 = 2³. Because the octal base is an exact power of the binary base, each octal digit corresponds to a fixed number of binary digits -- specifically, three.

This means:

  • Octal digit 0 = binary 000
  • Octal digit 1 = binary 001
  • Octal digit 7 = binary 111

Every possible combination of three binary bits (there are exactly 2³ = 8 of them) maps to one of the eight octal digits. This is not a coincidence or an approximation. It is an exact structural relationship between the two number systems.

Compare this to decimal: converting binary to decimal requires positional arithmetic because 10 is not a power of 2. Converting binary to octal requires nothing more than grouping and substitution.

This same principle applies to hexadecimal (16 = 2^4, so each hex digit = 4 bits) but not to, say, base-5 or base-12, which have no clean power-of-two relationship.

The 3-Bit Grouping Method Step by Step

Converting binary to octal is a three-step mechanical process.

Step 1: Start from the Right and Group into 3-Bit Chunks

Take the binary number and, beginning at the rightmost (least significant) bit, divide it into groups of three.

For example, the binary number 110101011:

1 | 101 | 011    (grouped from right)

Step 2: Pad the Leftmost Group with Leading Zeros

If the leftmost group has fewer than three bits, add zeros on the left to complete it. This does not change the value of the number.

001 | 101 | 011    (padded)

Step 3: Replace Each 3-Bit Group with Its Octal Digit

Use the conversion table (provided in the next section) to substitute each group:

  • 001 = 1
  • 101 = 5
  • 011 = 3

Result: Binary 110101011 = Octal 153

That is the entire algorithm. No division, no modular arithmetic, no carrying -- just grouping, padding, and substitution.

3-Bit Quick Reference Table (000-111)

This is the core lookup table you need to memorize for binary-to-octal conversion. There are only eight entries:

BinaryOctalDecimal
00000
00111
01022
01133
10044
10155
11066
11177

Since octal digits range from 0 to 7, this table is exhaustive. Once you internalize these eight mappings, you can convert any binary number to octal by hand in seconds.

Worked Examples

Example 1: Short Binary (6 bits)

Binary input: 101110

Step 1: Group from the right: 101 | 110

Step 2: Both groups are already 3 bits. No padding needed.

Step 3: Convert:

  • 101 = 5
  • 110 = 6

Result: Octal 56 (decimal 46)

Example 2: Full Byte (8 bits)

Binary input: 11010110

Step 1: Group from the right: 11 | 010 | 110

Step 2: Pad the leftmost group: 011 | 010 | 110

Step 3: Convert:

  • 011 = 3
  • 010 = 2
  • 110 = 6

Result: Octal 326 (decimal 214)

Notice that one byte (8 bits) always produces either two or three octal digits, since 8 is not evenly divisible by 3. This is one reason hexadecimal (where one byte = exactly two hex digits) became more popular than octal for byte-oriented architectures.

Example 3: Odd-Length Binary (5 bits)

Binary input: 10011

Step 1: Group from the right: 10 | 011

Step 2: Pad: 010 | 011

Step 3: Convert:

  • 010 = 2
  • 011 = 3

Result: Octal 23 (decimal 19)

Example 4: Long Binary (16 bits)

Binary input: 1100100111010110

Step 1: Group from the right: 1 | 100 | 100 | 111 | 010 | 110

Step 2: Pad: 001 | 100 | 100 | 111 | 010 | 110

Step 3: Convert:

  • 001 = 1
  • 100 = 4
  • 100 = 4
  • 111 = 7
  • 010 = 2
  • 110 = 6

Result: Octal 144726 (decimal 51,670)

Example 5: All Ones

Binary input: 111111111 (nine 1-bits)

Step 1: Group: 111 | 111 | 111

Step 2: No padding needed (already aligned).

Step 3: Convert: 111 = 7, 111 = 7, 111 = 7

Result: Octal 777 (decimal 511)

This value is significant in Unix permissions -- chmod 777 grants read, write, and execute permissions to owner, group, and others.

Extended Conversion Table (0-127)

The following table lists binary, octal, and decimal values for numbers 0 through 127. This covers the full 7-bit ASCII range and the most commonly encountered values.

DecimalBinaryOctalDecimalBinaryOctal
0000 00000641 000 000100
1000 00101651 000 001101
2000 01002661 000 010102
3000 01103671 000 011103
4000 10004681 000 100104
5000 10105691 000 101105
6000 11006701 000 110106
7000 11107711 000 111107
8001 00010721 001 000110
9001 00111731 001 001111
10001 01012741 001 010112
11001 01113751 001 011113
12001 10014761 001 100114
13001 10115771 001 101115
14001 11016781 001 110116
15001 11117791 001 111117
16010 00020801 010 000120
17010 00121811 010 001121
18010 01022821 010 010122
19010 01123831 010 011123
20010 10024841 010 100124
21010 10125851 010 101125
22010 11026861 010 110126
23010 11127871 010 111127
24011 00030881 011 000130
25011 00131891 011 001131
26011 01032901 011 010132
27011 01133911 011 011133
28011 10034921 011 100134
29011 10135931 011 101135
30011 11036941 011 110136
31011 11137951 011 111137
32100 00040961 100 000140
33100 00141971 100 001141
34100 01042981 100 010142
35100 01143991 100 011143
36100 100441001 100 100144
37100 101451011 100 101145
38100 110461021 100 110146
39100 111471031 100 111147
40101 000501041 101 000150
41101 001511051 101 001151
42101 010521061 101 010152
43101 011531071 101 011153
44101 100541081 101 100154
45101 101551091 101 101155
46101 110561101 101 110156
47101 111571111 101 111157
48110 000601121 110 000160
49110 001611131 110 001161
50110 010621141 110 010162
51110 011631151 110 011163
52110 100641161 110 100164
53110 101651171 110 101165
54110 110661181 110 110166
55110 111671191 110 111167
56111 000701201 111 000170
57111 001711211 111 001171
58111 010721221 111 010172
59111 011731231 111 011173
60111 100741241 111 100174
61111 101751251 111 101175
62111 110761261 111 110176
63111 111771271 111 111177

You can verify any of these values using our binary to octal converter.

Converting Octal Back to Binary

The reverse process -- octal to binary -- is equally straightforward. Simply replace each octal digit with its 3-bit binary equivalent.

Step-by-Step Reverse Process

  1. Write down the octal number. Remove any prefix notation (such as a leading 0 in C/C++ or 0o in Python).
  2. Replace each octal digit with its 3-bit binary value. Use the same 8-entry lookup table from above.
  3. Concatenate the groups. The result is the full binary representation.
  4. Remove leading zeros (optional) to get the minimal binary form.

Worked Example: Octal 375 to Binary

Octal input: 375

  • 3 = 011
  • 7 = 111
  • 5 = 101

Result: 011111101 or, dropping the leading zero, 11111101 (decimal 253)

Worked Example: Octal 52 to Binary

Octal input: 52

  • 5 = 101
  • 2 = 010

Result: 101010 (decimal 42)

This bidirectional simplicity is a direct consequence of the 2³ = 8 relationship. The conversion is lossless, exact, and requires no arithmetic.

Programming Examples

Python

Python provides built-in support for both octal and binary:

Python27 lines
Highlighting code...
693 chars

JavaScript

JavaScript uses parseInt() and .toString() for base conversions:

JavaScript29 lines
Highlighting code...
764 chars

C

C requires a manual approach since there is no built-in base conversion for strings:

C34 lines
Highlighting code...
881 chars

All three implementations produce identical results. The manual grouping method mirrors exactly what you do when converting by hand, while the built-in functions (Python's oct(), JavaScript's .toString(8)) handle the grouping internally.

Practical Application: Unix/Linux File Permissions

The most visible everyday use of octal numbers in modern computing is Unix/Linux file permissions. If you have ever typed chmod 755 script.sh in a terminal, you have used binary-to-octal conversion -- whether you realized it or not.

How Unix Permissions Work

Every file and directory in a Unix-like system has three sets of permissions:

  • Owner (user who created the file)
  • Group (users in the file's group)
  • Others (everyone else)

Each set has three permission flags:

PermissionSymbolBinary BitValue
Readr14
Writew12
Executex11

Each set of three permissions maps to exactly 3 binary bits, which maps to exactly one octal digit. This is not a coincidence -- octal was chosen specifically because it aligns perfectly with the 3-bit permission groups.

Decoding chmod 755

The octal number 755 breaks down as:

WhoOctalBinaryPermissionsMeaning
Owner7111rwxRead + Write + Execute
Group5101r-xRead + Execute
Others5101r-xRead + Execute

So chmod 755 sets the full binary permission mask to 111 101 101, granting the owner full control while allowing everyone else to read and execute but not modify the file.

Common Permission Values

OctalBinarySymbolicTypical Use
777111 111 111rwxrwxrwxFull access for everyone (risky)
755111 101 101rwxr-xr-xExecutable scripts, directories
750111 101 000rwxr-x---Group-accessible executables
700111 000 000rwx------Private executables
644110 100 100rw-r--r--Regular files (web content)
600110 000 000rw-------Private files (SSH keys)
400100 000 000r--------Read-only (certificates)

Understanding binary-to-octal conversion makes chmod values intuitive rather than mysterious.

Octal in Computing History and Modern Usage

Historical Significance

Octal notation was dominant in early computing for a practical reason: many early computers used word sizes that were multiples of three. The PDP-8 (12-bit words), the UNIVAC 1108 (36-bit words), and the IBM 7090 (36-bit words) all had architectures where octal was the natural compact notation. A 12-bit word maps cleanly to four octal digits. A 36-bit word maps to twelve octal digits.

The octal prefix 0 in the C programming language is a direct heritage of this era -- Ken Thompson and Dennis Ritchie developed C on a PDP-11, and octal notation was the standard at Bell Labs. This convention persists in C, C++, Java, and other languages to this day (e.g., 0755 in C is octal 755, decimal 493).

Why Hex Largely Replaced Octal

The shift from octal to hexadecimal occurred as the industry standardized on 8-bit bytes. Since 8 is not divisible by 3, a single byte does not map cleanly to a whole number of octal digits (it requires 2.67 octal digits). In contrast, one byte maps to exactly two hex digits. As byte-addressable architectures (Intel 8080, Zilog Z80, Motorola 68000) became dominant, hexadecimal became the preferred notation.

Where Octal Is Still Used Today

Despite hexadecimal's dominance, octal remains relevant in several areas:

  • Unix/Linux file permissions: chmod, umask, and stat all use octal
  • C/C++ octal literals: Any integer literal with a leading 0 (e.g., 0755) is interpreted as octal
  • Python octal literals: The 0o prefix (e.g., 0o755)
  • Escape sequences: Some programming languages use \nnn (octal) for character escapes
  • Aviation transponder codes: Aircraft squawk codes are four-digit octal numbers (0000-7777)
  • Legacy systems: Mainframe code and documentation from the 1960s-1970s frequently use octal

Frequently Asked Questions

How do you convert binary to octal?

Group the binary digits into sets of three from right to left, padding the leftmost group with leading zeros if necessary. Then replace each 3-bit group with its octal equivalent (000=0, 001=1, 010=2, 011=3, 100=4, 101=5, 110=6, 111=7). For example, binary 11010110 groups as 011 010 110, which converts to octal 326.

Why does binary-to-octal conversion use groups of 3?

Because 8 = 2³. The octal base (8) is the third power of the binary base (2), which means exactly three binary bits are needed to represent all possible values of a single octal digit (0 through 7). This mathematical relationship makes the conversion a direct substitution with no arithmetic required.

What is binary 11111111 in octal?

Binary 11111111 (decimal 255) converts to octal 377. Grouping from the right: 011 111 111, which gives 3-7-7. This is the maximum value of one byte in octal notation.

How do you handle binary numbers that are not a multiple of 3 digits?

Pad the leftmost group with leading zeros. For example, binary 10011 has 5 digits. Grouped from the right: 10 011. Pad the left group: 010 011. Convert: 2-3. The result is octal 23. Adding leading zeros does not change the numerical value.

What is the difference between octal and hexadecimal?

Octal is base-8 (digits 0-7) and each digit represents 3 binary bits. Hexadecimal is base-16 (digits 0-9, A-F) and each digit represents 4 binary bits. Hex is more common in modern computing because it aligns with 8-bit bytes (2 hex digits = 1 byte), while octal is still used for Unix file permissions and in legacy systems.

Why does chmod use octal numbers?

Each file permission set (owner, group, others) consists of three binary flags: read (r), write (w), and execute (x). Three binary flags map directly to one octal digit (since 2³ = 8). This makes octal the most natural and compact notation for expressing Unix permissions. For example, rwxr-xr-x = 111 101 101 = 755 in octal.

Can you convert octal to binary directly?

Yes -- simply replace each octal digit with its 3-bit binary equivalent. Octal 47 becomes 100 111 (binary). The process is the exact reverse of binary-to-octal conversion and is equally mechanical. No division or multiplication is needed.

What is octal 777 in binary and decimal?

Octal 777 equals binary 111 111 111 (nine 1-bits) and decimal 511. In Unix permissions, chmod 777 grants full read, write, and execute permissions to the owner, group, and all other users.

Summary

Binary-to-octal conversion relies on one foundational fact: 8 = 2³, so each octal digit maps to exactly three binary bits. Whether you are converting a 3-bit value or a 64-bit address, the algorithm is always the same: group into threes from the right, pad the leftmost group, and substitute.

The key takeaways from this guide:

  • Group binary digits into 3-bit chunks from the right and replace each group with its octal digit (000-111 maps to 0-7)
  • Pad the leftmost group with zeros if the total number of bits is not a multiple of three
  • Unix file permissions are the most common modern use of octal, with each rwx triplet mapping to one octal digit
  • Programming languages provide built-in conversion: Python's oct(int(x, 2)), JavaScript's parseInt(x, 2).toString(8), and manual grouping in C
  • The reverse conversion (octal to binary) works by replacing each octal digit with its 3-bit binary value
  • Octal was historically dominant on systems with word sizes divisible by 3, but hexadecimal took over as 8-bit bytes became standard

Ready to practice? Use our free binary to octal converter to convert any binary value to octal instantly, with step-by-step 3-bit group visualization and automatic padding.

About This Article

This article is part of our comprehensive converters cipher tutorial series. Learn more about classical cryptography and explore our interactive cipher tools.

More Converters Tutorials

Try Converters Cipher Tool

Put your knowledge into practice with our interactive convertersencryption and decryption tool.

Try Converters Tool