Skip to content
ZeroServer.tools

Text to Octal

Convert text to octal (base-8) codes — one value per character.

What is octal encoding?

Octal (base 8) uses digits 0–7. Each character's Unicode code point is expressed as a base-8 number. ASCII letters A–Z map to octal 101–132, and a–z map to 141–172. Octal was common in early Unix systems — chmod permissions (755) use octal. For example, 'H' is decimal 72, which is 110 in octal.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Writing a C or shell string literal where a character has to appear as an octal escape rather than itself.
  • Producing octal values for a file permission or legacy-format exercise that expects base eight.
  • Cross-checking a value read out of an old dump or a system that reports in octal.
  • Building a teaching example that shows why base eight groups bits in threes.
  • Encoding a short string for a puzzle whose answer is deliberately in an unfamiliar base.

Frequently Asked Questions

What does octal output look like?
Three digits per byte, since 8-bit values run to 377 octal (255 decimal). 'A' is 101, 'a' is 141. That fixed three-digit width is what makes the stream parseable without separators.
Where is octal text encoding actually used?
In string escapes — \101 for 'A' in C, Python and shell — and in the output of od -c and some tar headers. Modern code overwhelmingly prefers \x hex escapes, so octal escapes mostly appear in older sources.
Why can an octal byte never start with 8 or 9?
Because those digits do not exist in base 8 — the digits are 0-7 only. Seeing an 8 or 9 in supposed octal output is a reliable sign that the value is actually decimal.
What is the highest first digit for a byte?
3. A byte holds 8 bits and each octal digit is 3 bits, so three digits cover 9 bits — the leading digit uses only 2 of them and therefore ranges 0-3. Anything higher is out of byte range.
How do escapes differ between languages?
C and Python take up to three octal digits after a backslash; some shells require exactly three. Python 3 additionally warns on invalid escapes, and \0 is the null byte in all of them — a real hazard in C strings.
Why do C-style octal escapes stop at three digits?
Because the standard limits them, so `\1234` is the byte 0o123 followed by a literal `4`. A four-digit octal value cannot be written as one escape, which is a frequent off-by-one when hand-writing binary strings.
What is the trap with leading zeros in source code?
In C, Java and older JavaScript, a numeric literal starting with 0 is octal — so `010` is 8, not 10. It is why zero-padding a number in code silently changes its value, and why modern languages require an explicit `0o` prefix.

Common errors and gotchas

  • Including an 8 or a 9. Base eight has neither, so their presence means the input was decimal all along.
  • Assuming a C octal escape can run past three digits. It stops at three, and a fourth digit becomes a separate character.
  • Writing a leading zero in source code and getting octal by accident, which is how `010` quietly becomes eight.
  • Expecting a byte's first octal digit to exceed three. It cannot, since three digits only reach 255 when the first is 0 to 3.
  • Mixing separators so values run together, which makes a two-digit and a three-digit value impossible to tell apart.

Related Encoders & Decoders tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate