Convert Gray Code to Octal

Decode Gray code (reflected binary) to octal, decimal, binary, or hex. BigInt-safe, per-line errors, Unix permission helper. Free, offline, 100% client-side.

Decode reflected binary (Gray code) bits into octal (base-8). Useful for compact Gray-encoded logs, rotary encoder position dumps, and converting 9-bit Gray values into chmod-style Unix permissions.

Enter Gray code to convert.

How to Use Convert Gray Code to Octal

  1. Paste your binary Gray code, one value per line. You can include the 0b prefix or visual separators like spaces and underscores (1011_0110); the tool strips them before decoding.
  2. Choose the output format: octal (default), decimal, the decoded binary bits, hex, or all five columns side by side for spreadsheet paste.
  3. Toggle the 0o prefix if your target audience expects Python/ES6-style octal literals; leave it off for bare chmod-style digits.
  4. Enable "Show Unix permissions" if your Gray values represent 3-digit (or 4-digit with sticky/setuid) file modes. The breakdown then adds a rwxr-xr-x line next to each decoded octal.
  5. Press Convert (or Ctrl+Enter / Cmd+Enter). Auto-convert fires 200 ms after each keystroke so results appear as you type.
  6. Read the stats row: total lines, successful vs failed, max bit width, and the largest decimal decoded. Inspect the breakdown panel for each row's Gray → Binary → Decimal → Octal chain.
  7. Errors are per line: a stray character shows a red row naming the position while every other line still converts. Copy or Download captures only the successful values.

Frequently Asked Questions

How is Gray code decoded to octal?

In two logical stages. Stage one is Gray → standard binary via the MSB-first XOR chain (binary[0] = gray[0]; then binary[i] = binary[i-1] ⊕ gray[i]). Stage two is binary → octal: group the binary from the right into chunks of 3 bits; each chunk becomes one octal digit 0-7. Example: Gray 111101101 → Binary 101110110 → Octal 566.

Does this handle Gray codes larger than 2^53?

Yes. The octal render uses JavaScript’s native BigInt, which has no fixed upper bound. A 256-bit or 1,024-bit Gray code produces its exact octal representation – ordinary Number arithmetic would silently round past 9,007,199,254,740,991 (253 − 1) and give wrong answers. BigInt prevents that entirely.

Why would I want octal output in 2026?

Three real use cases. One: Unix file permissions – chmod 755 is still the canonical form. Two: legacy PDP-11/VMS systems and microcontroller datasheets that specify values in octal. Three: compact binary display when hex is too dense – 3-bit octal digits map neatly onto 9-bit or 12-bit fields common in older ADC and DSP hardware.

What does the Unix permissions helper do?

When enabled and the octal value is 3 or 4 digits, the breakdown shows the symbolic mode string. 755 → rwxr-xr-x, 644 → rw-r--r--, 1755 → rwxr-xr-t (with sticky bit), 4755 → rwsr-xr-x (with setuid). Values of other digit counts are skipped.

What happens if my Gray code isn’t a multiple of 3 bits?

The octal output is still correct – it just uses the minimum octal digits needed. 4-bit Gray 1011 decodes to binary 1101 (13), which is octal 15 (two digits). There’s no forced zero-padding to align to 3-bit chunks; if you need padding, prepend zeros to the input manually.

What if one line has a bad character?

Only that line fails. The tool walks the input line-by-line, so a stray 2 in one row becomes a single red entry (“Line 3: invalid character ‘2’ at position 2”) in the breakdown while every other line still converts. The stats row shows exactly how many succeeded versus failed, and Copy/Download capture only the good results.

Is my data safe here?

Yes. Every byte of processing happens in your browser’s JavaScript engine – nothing is uploaded, logged, or retained by any server. You can open the Network tab in DevTools to confirm: no requests fire during conversion. The page keeps working after you disconnect from the internet.

What’s the difference between 0o755 and 755?

Only the prefix. 0o755 is the Python 3 / ES6 / Rust literal form that tells a compiler or interpreter “this is octal, not decimal.” 755 is the bare form used by Unix chmod and most shell tooling. The tool’s “Include 0o prefix” toggle lets you choose which your downstream consumer expects.

Can I round-trip a value (Gray → octal → back to Gray)?

Yes – the conversion is lossless. Decode a Gray value to octal here, then use an octal-to-binary-to-Gray-code tool (or an octal-to-Gray-code converter) and you’ll recover the original bits. The Gray ↔ binary mapping is bijective, and binary ↔ octal is bijective for any bit width.

How fast is this for large batches?

Fast. The decoder is O(n) in total bit length and the BigInt octal render is O(digits). 10,000 lines of 64-bit Gray code finish under 100 ms on a modern laptop. The breakdown caps display at 50 rows for layout performance, but the output textarea always contains every successful conversion.