Built and fact-checked by the DocNectar team — see our editorial standards
Key Features
Instant Calculation
Get accurate results in real time with our optimized algorithm.
Mobile Friendly
Fully responsive design. Works on all devices & screen sizes.
Privacy Focused
Your data stays on your device. We don't store any inputs.
100% Free
No hidden costs. This tool is completely free forever.
Gray code is a binary numbering system where two consecutive values differ in only one bit, which prevents errors in applications like rotary encoders where multiple bits could otherwise change at slightly different times.
This calculator converts between standard binary and Gray code in either direction.
How it works
Choose a direction and enter a binary value. Converting to Gray code XORs the binary number with itself shifted one bit right. Converting back to binary folds the bits left to right, XOR-ing each bit with the previous result.
- Enter direction.
- Enter value (binary digits).
- Click Calculate to see your results.
Examples
Binary 1011 to Gray
The binary number 1011 converts to the Gray code 1110.
Who should use it
- Understanding rotary encoder and digital hardware design.
- Coursework involving digital logic and error-correcting codes.
Industry applications
- Digital electronics and hardware design
- Computer science education
Advantages
- Reduces errors from multi-bit transitions in hardware and communication systems.
- Works in both directions from a single tool.
Limitations
- Less intuitive to read directly as a numeric value than standard binary.
Common mistakes to avoid
- Entering a decimal number instead of a binary string — this tool expects binary digits (0s and 1s) as input.
- Confusing Gray code with binary-coded decimal (BCD), which is a different encoding scheme entirely.
Best practices
- When converting a series of sequential values, verify that each consecutive pair of Gray code results differs by exactly one bit — that's the defining property of Gray code.
Tips
- To see the "adjacent values differ by one bit" property in action, convert a short run of consecutive binary numbers (000, 001, 010, 011...) to Gray code and compare each result to the one before it.