Base64 to octal byte values
The Base64 to octal converter decodes Base64 and writes each byte as a three-digit octal number. Every value is zero-padded — 041 rather than 41 — so the output lines up neatly and can be split reliably even without separators.
Example
Base64 input:
SGkhOctal output:
110 151 041110, 151 and 041 are the octal codes for “H”, “i” and “!”.
Building C and shell escapes
Octal output is handy for writing byte-exact string literals. Prefix each value with a backslash to get C, Perl or shell escapes — \110\151\041 — which printf '\110\151\041' prints as “Hi!”. Choose the “None” separator to get one continuous run of digits and insert backslashes every three characters.
Separator options
- Space — the format used by od -b and most documentation.
- None — continuous three-digit groups, compact for scripts.
- Comma — for pasting into arrays or spreadsheets.
Reading octal quickly
A three-digit octal byte splits neatly into bits: the first digit holds the top two bits and the other two digits three bits each. So 151 is 01 101 001 in binary — 105 decimal, the letter “i”. This is also why Unix file permissions such as 755 are written in octal: each digit is exactly three permission bits.
Typical uses
- Writing byte-exact test strings for C programs, shell scripts and printf-based tooling.
- Preparing values for PostgreSQL’s escape-format
bytealiterals. - Comparing a Base64 payload with an od -b dump from a Unix system.
- Teaching and exercises on number systems and byte encodings.
On the command line
echo SGkh | base64 -d | od -An -b prints the same octal bytes in a terminal, and Python’s ' '.join(f'{b:03o}' for b in base64.b64decode(s)) does it in a script. The tool is quicker for a one-off check and works the same on every operating system.
Input handling
Standard and URL-safe Base64 are accepted, whitespace is ignored and padding is optional. For other views of the same bytes, use Base64 to Hex or Base64 to Binary. To go back from octal to Base64, use Octal to Base64. Everything runs in your browser.
Octal escapes in other languages
Three-digit octal escapes are not understood everywhere, so check the target before pasting \110\151\041 into code:
| Language | Octal escapes? | Notes |
|---|---|---|
| C, C++, Perl | Yes | At most three digits are read, so \1101 is “H” followed by “1”. |
| Python | Yes | Works in both str and bytes literals. |
| Java | Yes | Allowed from \0 to \377. |
| JavaScript | No | A syntax error in strict mode and template literals; use \x48 instead. |
| JSON | No | Only \u0048-style escapes are valid. |
In Bash, printf reads the \110 form, while echo -e expects a leading zero, as in \0110. When a language rejects octal, Base64 to Hex gives you values for \x escapes instead.