Skip to content

Decimal to Octal Converter

Type decimal integers and get their exact octal form, with a 0o prefix, grouping or fixed-width two’s complement when you need it.

Processed locally in your browser

Options

Two’s complement writes a negative number as a fixed-width bit pattern (range −2^(N−1) … 2^N−1).

One number per line. Spaces and underscores inside a number are ignored.0 chars · 0 lines
The result will appear here.

What is Decimal to Octal Converter?

Converting to octal means repeatedly dividing by 8 and reading the remainders backwards, or grouping the binary form three bits at a time. The result uses only the digits 0 to 7. Octal is still the notation of Unix permission modes: read = 4, write = 2 and execute = 1 add up to one digit per user class, so 493 becomes 755.

This tool reads one integer per line and works with arbitrary-precision arithmetic, so a 30-digit decimal is converted without rounding. Negative numbers can be written with a minus sign or as an 8, 16, 32 or 64-bit two’s-complement pattern (−1 in 8 bits is 377). You can add the 0o prefix, group digits by 3 or 4 and pad to a fixed number of digits.

How does it work?

  1. Enter one decimal integer per line, for example 493 or -5.
  2. Choose how negatives are written: with a minus sign or as two’s complement in a fixed bit width.
  3. Turn on the 0o prefix, digit grouping or padding if your target needs it.
  4. Copy the octal output; for a single number the rows also show binary, hexadecimal and bit length.

Common use cases

  • Finding the chmod mode for a permission value given in decimal, such as 493 for 755.
  • Preparing octal literals for Python (0o755), JavaScript, Rust or a C source file.
  • Producing octal escape codes or fixed-width octal fields for a tar, cpio or legacy file format.
  • Checking that a hand conversion for an exam or exercise is correct.

Examples

Try this input in the tool above:

Input
493
511
-5
123456789012345678901234567890
Output
755
777
-5
143564417755415637016711617605322

Privacy

Decimal to Octal Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Only whole numbers are converted (fractions belong in the Base Converter). Two’s complement output requires the value to fit in the chosen width, otherwise an error is shown.

Frequently asked questions

What is 493 in octal?

493 in decimal is 755 in octal, since 7×64 + 5×8 + 5 = 493. That is the familiar chmod 755 mode.

How is a negative number shown in octal?

By default with a minus sign, for example −5 stays −5. With two’s complement 8-bit, −5 becomes 373, which is the octal writing of the bit pattern 11111011.

Does the 0o prefix change the value?

No. 0o755 and 755 are the same number. The prefix only tells languages such as Python, JavaScript and Rust that the literal is octal; older C code uses a plain leading 0.

More tools in Developer Tools →