Free browser converter
Binary to Octal Converter
Group binary digits from the right in sets of three and convert them to exact octal digits, with strict validation and preserved leading groups.
Interactive tool
Convert binary integers to octal digits
Ready
Choose the exact representation you need; the tool does not guess an encoding.
Detailed conversion guide
How to Convert Binary to Octal
Starting at the right, split the binary number into three-bit groups. Each group maps to one octal digit: 111 is 7 and 101 is 5, so 111101101 becomes 755.
If the leftmost group is short, zeros are added on the left. Direct group mapping preserves display width and exactness for inputs beyond the safe integer range.
| Input | Output | Meaning |
|---|---|---|
000 | 0 | one group |
101 | 5 | one group |
111111 | 77 | two groups |
111101101 | 755 | three groups |
Binary to Octal in JavaScript and Python
Validate 0 and 1, left-pad to a multiple of three, and convert each three-bit group independently. This avoids Number precision loss.
const bits = input.replace(/[_\s]/g, "");
if (!/^[01]+$/.test(bits)) throw new Error("Invalid binary");
const padded = bits.padStart(Math.ceil(bits.length / 3) * 3, "0");
const octal = padded.match(/.{3}/g).map(x => parseInt(x, 2)).join("");Three-Bit Groups, Leading Zeros, and Invalid Binary
A 0b prefix and visual spaces or underscores are syntax, not digits. Prefixed output adds 0o to document base 8.
Digits 2-9, signs, fractions, and prose are unsupported. The converter never truncates at an invalid character or returns a partial value.
Related converters
Continue converting ASCII and Unicode
Choose the converter for the direction and representation you need.