Since 2010 · Powering 2M+ tool runs every month
Since 2010
Add to Chrome

My Toolbox

Automatic Mode

No saved tools yet.

Go Premium
Related tools
Binary to Octal ConverterBinary CalculatorOctal to Hex ConverterHEX Calculator
Home Page > Miscellaneous > Number System Converters

About Binary to Gray Code Converter

Welcome to our Binary to Gray Code Converter, a free online tool that converts standard binary numbers into Gray code (reflected binary code). This converter shows the XOR rule, a clear bit-by-bit diagram, and a step-by-step breakdown so you can understand how the conversion works.

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. This is useful in rotary encoders, digital communications, and other systems where multiple changing bits can cause errors during transitions.

How to Convert Binary to Gray Code

A common formula is:

In bit form, the most significant Gray bit equals the most significant binary bit. Every next Gray bit is the XOR of two adjacent binary bits.

This conversion changes the bit pattern (the code), not the underlying integer value represented by the original binary input.

How to Use This Converter (HowTo)

  1. Enter your binary number using only 0 and 1 (optional prefix: 0b).
  2. Click the convert button.
  3. Review the output Gray code, then scroll to see the shift-and-XOR diagram and the step-by-step details.

The diagram below shows how the formula works on a short example.

Example: Binary 1011 to Gray code

Binary:
1
0
1
1
Binary >> 1:
0
1
0
1
XOR Result:
1
1
1
0

Understanding XOR

XOR (exclusive OR) outputs 1 when the two input bits are different, and 0 when they are the same. The XOR truth table is shown above the input form on this page.

Where Gray Code is Used

FAQ

What is Gray code?

Gray code is a binary numeral system where consecutive values differ by exactly one bit. This property helps reduce errors during transitions in real-world devices such as rotary encoders.

How do you convert binary to Gray code?

You can compute Gray code by XORing the binary number with the same number shifted right by one bit: Gray = Binary XOR (Binary >> 1). This tool shows the shift row and the XOR result row so you can verify each bit.

Does Gray code represent the same decimal value as the input?

Gray code is a different encoding of the same sequence index, not a different base. If you interpret the Gray bits as a normal binary number, you usually get a different decimal value. That is why this page shows the Gray bits interpreted as binary only as a reference.

Can I convert Gray code back to binary?

Yes. Use our Gray Code to Binary Converter. The reverse conversion can also be done bit by bit using XOR with the previously recovered binary bit.

Additional Resources

Reference this content, page, or tool as:

"Binary to Gray Code Converter" at https://MiniWebtool.com/binary-to-gray-code-converter/ from MiniWebtool, https://MiniWebtool.com/

by miniwebtool team. Updated: Dec 20, 2025

Number System Converters:

Top & Updated:

Binary to Hex ConverterOctal to Binary ConverterBinary to Decimal ConverterView all →
Home Page > Miscellaneous > Number System Converters > Binary to Gray Code Converter