Binary to Gray Code Converter
Convert a binary number to Gray code with a step-by-step explanation, XOR truth table, and bit-by-bit visualization.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
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:
- Gray = Binary XOR (Binary shifted right by 1)
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)
- Enter your binary number using only 0 and 1 (optional prefix: 0b).
- Click the convert button.
- 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
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
- Rotary encoders: reduces misreads when moving between positions
- Digital electronics: avoids glitches when multiple bits change at once
- Error-sensitive transitions: helps minimize transient state ambiguity
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
Related MiniWebtools:
Number System Converters:
- BCD to Binary Converter Featured
- BCD to Decimal Converter Featured
- BCD to Hex Converter Featured
- Binary to BCD Converter Featured
- Binary to Gray Code Converter Featured
- Decimal to BCD Converter Featured
- Gray Code to Binary Converter Featured
- Hex to BCD Converter Featured