Octal to Binary

Expand octal values into their binary bit patterns, one line at a time.

Octal
Binary
Runs locally in your browser

About the Octal to Binary

Every octal digit stands for a fixed triple of bits, so expansion is a straight substitution: 7 becomes 111, 5 becomes 101, 4 becomes 100. The familiar file mode 755 therefore expands to 111101101, which is the owner, group and other permission bits laid out in order. Reading a mode as bits is the quickest way to explain why 755 grants write access to nobody but the owner.

Each line is expanded on its own, so a whole column of modes copied from ls -l output or a Dockerfile can be pasted at once. Values may carry a 0o prefix or the bare leading zero that C and older shells use. Digits 8 and 9 are rejected with a message naming the character, since octal only runs from 0 to 7 and a stray 8 usually means the value was actually decimal.

Leading zeros are dropped from the result unless Group digits is on, which pads to whole nibbles and spaces them in fours for readability. That padded form lines up neatly when you are comparing two modes by eye. Use Show source value to keep the octal beside its expansion when you are documenting a change. The reverse direction lives at Binary to Octal, and mode bits are explained in plain words by the Unix Permission Calculator.

How to use

  1. Paste the octal values or file modes into the left pane, one per line.
  2. Turn on Group digits to space the bits in groups of four.
  3. Turn on Show source value to keep each octal value next to its bits.
  4. Copy the binary column when you are done.

Common questions

Why does 755 expand to nine bits?
Each of the three octal digits becomes three bits, giving the nine permission bits for owner, group and other.
Is a leading zero required?
No. Values are always read as octal on this page, so 0755 and 755 give the same bits.
What does the error about digit 8 mean?
Octal has no 8 or 9. Seeing one usually means the value was decimal, so convert it with the Number Base Converter instead.
Why are leading zeros missing from short values?
Magnitude is preserved without padding by default. Switch on Group digits to pad the output to whole groups of four bits.