FormatterHQ

Base64 to Octal

Decode Base64 into octal byte values, each written as three digits from 000 to 377, with your choice of separator.

Loading tool…
Ready.

How to use the Base64 to Octal

  1. Type or paste into the Base64 box, or click Sample. You can also drop a text file on either box, or load one into the Base64 box with its Open file button.
  2. The Octal box updates live as you type. It works both ways — edit the Octal side to convert back, or click ⇄ Swap to exchange the sides.
  3. Adjust Separator in the options bar above the editors; the result refreshes immediately. Alphabet only affects the reverse direction, when you type in the Octal box.
  4. Use Copy or Download on either box to take the result, or Clear to start again.

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:

SGkh

Octal output:

110 151 041

110, 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 bytea literals.
  • 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:

LanguageOctal escapes?Notes
C, C++, PerlYesAt most three digits are read, so \1101 is “H” followed by “1”.
PythonYesWorks in both str and bytes literals.
JavaYesAllowed from \0 to \377.
JavaScriptNoA syntax error in strict mode and template literals; use \x48 instead.
JSONNoOnly \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.

Frequently asked questions

Why are the octal values always three digits?
Each byte is zero-padded to three digits (000 to 377), which keeps columns aligned and lets you split continuous output reliably.
How do I turn the output into C escapes?
Put a backslash before each three-digit value, for example \110\151\041. C, Perl and printf interpret these as bytes.
What is 377 in octal?
377 octal is 255 decimal (FF hex), the largest value a byte can hold.
Does it accept Base64URL?
Yes. URL-safe characters and missing padding are handled automatically.

Last updated October 3, 2026

Related tools