Tools

Home
Text to BinaryBase64 Encode/DecodeHash GeneratorUTF-8 Encode/DecodeURL Encode/Decode

Gray Code to Binary Converter

Convert Gray code (reflected binary) to standard binary online. Supports multiple numbers, decimal display, and bit padding.

Your files never leave your browser
INPUT (GRAY CODE)0 values
OUTPUT (BINARY)0 values
Ready·Gray Code to Binary

Paste a Gray code value and see the standard binary side by side — the kind of thing you want when you're debugging a rotary encoder or sanity-checking a Karnaugh map. Handles lists of numbers at once, pads to 4, 8, or 16 bits, and can show the decimal next to each result. And everything runs in your browser. Nothing gets uploaded.

How to Use

Enter Gray code values in the left panel, one per line. You can type, paste, or click Sample for example data.

Choose bit padding (Auto, 4-bit, 8-bit, or 16-bit) and optionally enable Show decimal equivalent to see the base-10 value alongside each result.

Click Convert or leave Live mode enabled for real-time conversion as you type.

Copy, Download, or Swap the result. Swap converts binary values back to Gray code.

Frequently Asked Questions

What is Gray code?

Gray code (also called reflected binary code) is a binary numeral system where two successive values differ in only one bit. It was invented by Frank Gray at Bell Labs and is widely used in rotary encoders, error correction, Karnaugh maps, and digital communications to minimize errors during transitions between values.

How does the Gray-to-binary conversion algorithm work?

The most significant bit (MSB) of the binary result is the same as the MSB of the Gray code input. For each subsequent bit position, the binary bit is calculated by XOR-ing the current Gray code bit with the previous binary bit. For example, Gray code 1101 converts to binary 1001: the first bit stays 1, then 1 XOR 1 = 0, then 0 XOR 0 = 0, then 0 XOR 1 = 1.

Why is Gray code preferred over standard binary in some applications?

In standard binary, transitioning between consecutive numbers can require multiple bits to change simultaneously (e.g., 0111 to 1000 changes all four bits). This can cause transient errors in hardware. Gray code ensures only one bit changes per step, eliminating glitches in rotary encoders, analog-to-digital converters, and other systems where simultaneous bit changes could produce incorrect intermediate values.

What does bit padding do?

Bit padding adds leading zeros to make all output values a uniform width. "Auto" uses the natural length of each value, "4-bit" pads to 4 digits (e.g., 0101), "8-bit" pads to 8 digits (e.g., 00000101), and "16-bit" pads to 16 digits. This is useful when working with fixed-width registers or when you need consistently formatted output.

Can I convert binary back to Gray code?

Yes. Click the Swap button to switch from Gray-to-binary mode into binary-to-Gray mode. The output will move to the input panel and the tool will convert standard binary values back to their Gray code equivalents using the reverse algorithm: the MSB stays the same, and each subsequent bit is the XOR of two adjacent binary bits.

Share: