Gray Code Converter
Free online Gray code converter. Convert decimal to Gray code, binary to Gray code, and back instantly. No signup required.
Loading tool...
What is Gray Code Converter?
A Gray Code Converter translates numbers between decimal, plain binary, and Gray (reflected binary) code. In Gray code, consecutive integers differ by exactly one bit, which prevents glitches in hardware and simplifies Karnaugh-map and encoder design.
Key Benefits
- Instant three-way conversion as you type
- Bidirectional: encode to Gray and decode back to binary/decimal
- Arbitrary-precision BigInt for huge values
- Clear validation for invalid digits
- 100% client-side β nothing is uploaded
Common Use Cases
- β’Digital-electronics students verifying Gray code tables
- β’Engineers designing rotary or angular encoders
- β’Developers working on Karnaugh maps and glitch-free logic
- β’Anyone learning reflected binary code concepts
How to Use the Gray Code Converter
- Pick an input format: Choose Decimal, Binary, or Gray as the format of the value you want to convert.
- Enter your value: Type or paste the number. The tool converts automatically as you type and validates the digits.
- Read the three outputs: The results show the equivalent Decimal, Binary, and Gray code representations side by side.
- Copy a result: Click Copy next to any output to copy it to your clipboard for use in schematics or code.
Key Features
- Three-way conversion: decimal, binary, and Gray (reflected binary) code
- Instant bidirectional decode β Gray to binary and binary to Gray
- Arbitrary-precision BigInt handles arbitrarily large values
- Real-time results with clear invalid-input validation
- One-click copy for every output format
- 100% client-side β your data never leaves the browser
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. Named after Frank Gray, it is used to prevent spurious output from electromechanical switches and in error correction, Karnaugh maps, and rotary or angular encoders.
How do you convert binary to Gray code?
The most significant bit stays the same. Each subsequent Gray bit is the XOR of the current and previous binary bits. Mathematically: Gray = binary XOR (binary shifted right by one bit).
How do you convert Gray code back to binary?
Starting from the most significant bit, each binary bit is the XOR of all Gray bits from the MSB down to that position. This tool performs that reverse automatically using arbitrary-precision arithmetic.
Does this tool support very large numbers?
Yes. It uses JavaScript BigInt, so it handles arbitrarily large integers without the 53-bit precision limit of regular numbers, as long as the input is a valid digit string.