Octal Text Converter

Convert text to octal byte values — like \033 in shell scripts

Encodes each UTF-8 byte of your text as its octal value, and decodes space-separated octal back to text. Useful for shell escapes, C string literals, and low-level byte inspection. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How is each byte converted to octal?

The text is encoded as UTF-8 bytes, and each byte (0 to 255) is written in base 8. A byte value of 65 (the letter A) becomes 101 in octal, since 1×64 plus 0×8 plus 1 equals 65.

Octal byte values show up wherever bytes are written in base 8 — shell escape sequences, C and Python string literals, and classic Unix tools. This converter turns text into octal byte values and back.

Why octal? The historical roots

Octal (base 8) survived in computing long after hexadecimal became the dominant notation because early Unix and C used three-bit nibbles rather than four-bit ones in some contexts. Three octal digits can represent exactly one byte (0–255), while three hex digits span 0–4095. The octal escape \0nn notation in C predates \xNN hex notation and is still valid in every C standard.

The most practical remnant is Unix file permissions. The chmod command accepts octal: chmod 755 sets permissions rwxr-xr-x, because each permission group (owner, group, other) is three bits — readable as a single octal digit.

How the conversion works

For encoding, the text is converted to UTF-8 bytes. Each byte from 0 to 255 is written in base 8, which needs at most three octal digits:

byte 65  (A)   -> 101
byte 27  (ESC) -> 033
byte 255       -> 377
byte 32  (space) -> 40

For decoding, the input is split on whitespace, each token is parsed as a base-8 number, and the resulting bytes are decoded as UTF-8 into text. Any token that is not valid octal, or exceeds 377 (255 decimal), is rejected.

Where octal escapes appear in practice

Shell scripts: The escape character (\033) is used to write ANSI terminal colour codes. Example: echo -e "\033[31mRed text\033[0m" prints “Red text” in red on most terminals. The \033 is octal for byte 27 (ESC).

C string literals: Any byte can be embedded in a C string with \nnn where nnn is up to three octal digits. "\101" is the letter A, "\007" is the bell character. These still work in modern C and C++.

Python strings: Python accepts octal escapes in byte strings: b"\101" is b'A'. Python 3 also accepts \x41 (hex) for the same byte.

printf in shell: printf '%o\n' 65 prints 101. printf '\101' prints A by interpreting the octal escape.

Worked examples

The word Hi:

  • H = byte 72 = octal 110
  • i = byte 105 = octal 151
  • Encoded: 110 151

The ANSI escape sequence prefix ESC[:

  • ESC = byte 27 = octal 033
  • [ = byte 91 = octal 133
  • Encoded: 033 133

A multibyte UTF-8 character, for example é (U+00E9):

  • UTF-8 encoding: two bytes: 0xC3 (195) and 0xA9 (169)
  • Octal: 303 251
  • Decoding those two bytes back as UTF-8 recovers é

When decoding, separate each byte value with a space. The tool does not assume a fixed three-digit width, so 101 33 110 reads as three bytes (65, 27, 72), not as a single number.