Text to octal, plain and predictable
Text to octal encoding walks every character of your input, reads its UTF-16 char code with charCodeAt, and writes that integer as a base-8 string. ASCII characters (codes 0 through 127) fit in three octal digits or fewer, Latin-1 characters fit in three (since 255 is 377), and the rest of the Basic Multilingual Plane fits in up to six. The default behaviour zero-pads every chunk to three digits, which is the form most octal-to-text decoders expect.
Two toggles change the output shape. Pad Bytes, on by default, zero-pads every chunk to at least three octal digits with padStart(3, "0") so ASCII characters always emit a clean byte. Turn it off to emit the minimum number of octal digits per character. Separate, on by default, puts a single space between every chunk so the output reads as a stream of bytes. Turn it off to emit a continuous run of octal digits with no delimiter.
Octal is less common than hex or binary in modern systems, but it shows up in Unix file permissions (chmod 0755), legacy mainframe formats and a few embedded devices. Encoding text as octal is a useful step when interfacing with those systems. For the inverse direction, see octal to text.
How to use convert text to octal
- 1Paste your text into the input panel on the left.
- 2The octal stream appears in the output panel on the right as you type.
- 3Toggle Pad Bytes to zero-pad short chunks to three digits.
- 4Toggle Separate to insert a space between chunks.
- 5Click Copy in the output header to copy the result.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
UTF-16 char codes via charCodeAt
Each character is read with charCodeAt(0), which returns the UTF-16 code unit value. ASCII text encodes to values 0 through 127, Latin-1 to 0 through 255, and the rest of the Basic Multilingual Plane to up to 65535. Above-BMP characters encode as two 16-bit surrogate code units, one chunk each.
Pad Bytes toggle (default on)
On by default. Zero-pads every chunk to at least three octal digits with padStart(3, "0") so ASCII characters always emit a clean byte. Turn off to emit the minimum number of octal digits per character. With padding off, \n (char code 10) emits as 12, not 012.
Separate toggle (default on)
On by default. Inserts a single space between every chunk so the output reads as a stream of bytes. Turn off to emit a continuous run of octal digits with no delimiter. Continuous output needs Pad Bytes on to round-trip without a known chunk width.
Three digits cover every byte
A single byte (0 through 255) needs at most three octal digits, since 255 is 377. With padding on, every byte-sized character emits as a clean three-digit chunk, which makes the stream regular and easy to parse downstream.
Runs entirely in your browser
No upload, no server-side processing, no log of what you pasted. The encode runs on every keystroke via a single JavaScript pass. Long inputs of a few hundred kilobytes still encode in under a second on a desktop browser.
Worked example
Two characters become two three-digit octal chunks: H is char code 72 (110), i is char code 105 (151).
Hi
110 151
Settings reference
| Setting or rule | Effect on output |
|---|---|
| Separate (default on) | Inserts a single space between chunks. Turn off for a continuous run of octal digits. |
| Pad Bytes (default on) | Zero-pads each chunk to at least three octal digits. Turn off to emit minimum width. |
| Encoding | UTF-16 code unit value of each character via charCodeAt, then toString(8). |
| ASCII characters | Encode in 1-3 octal digits. Pad Bytes on always emits three digits. |
| Latin-1 characters | Always fit in three octal digits since 255 is 377. |
| Above-byte characters | Need more than three octal digits. With padding on, the chunk grows to the next sufficient width. |
| Empty input | Emits an empty string. |
FAQ
Why three digits per character?
377, the maximum for a single byte. Padding to three digits keeps ASCII output regular and round-trippable to a fixed-width octal decoder. Without padding, a low char code like 10 (\n) would emit as 12 instead of 012, which is ambiguous in a continuous stream.What does Separate do?
When is octal the right choice?
chmod 0755), legacy mainframe formats, some embedded device protocols, and the occasional textbook problem. Hex is more common in modern systems for byte-level work; binary is more common in embedded and low-level code. Use octal when the downstream tool expects it.Is the text sent anywhere?
How do I go the other way?
String.fromCharCode.