Free exact browser converter
Hex to Gray Code Converter
Convert hexadecimal integers to reflected binary Gray code online with exact BigInt arithmetic, strict hex validation, and optional 0b output.
Interactive tool
Convert Hex to Gray Code
Ready
Choose a clear output representation.
Detailed conversion guide
How to Convert Hex to Gray Code
Parse the hexadecimal integer exactly, then compute Gray = value XOR (value shifted right by one bit). Hex A is decimal 10, or binary 1010; 1010 XOR 0101 produces Gray 1111.
BigInt keeps the conversion exact beyond JavaScript's safe Number range. The result is a reflected binary Gray representation, not the ordinary binary spelling of the hex input.
| Input | Output | Meaning |
|---|---|---|
0 | 0 | zero boundary |
1 | 1 | one boundary |
A | 1111 | decimal 10 encoded as Gray |
FF | 10000000 | decimal 255 encoded as Gray |
Hex to Gray Code with BigInt
The algorithm validates the representation before exact integer conversion, so malformed input never produces a plausible partial answer.
const value = BigInt(`0x${hex}`);
const gray = value ^ (value >> 1n);
const bits = gray.toString(2);Hex Digits, Gray Semantics, and Unsupported Input
Digits 0-9 and A-F are accepted after an optional 0x prefix. Signs, fractions, two's-complement assumptions, and invalid digits are rejected without a partial result.
Leading hex zeros do not define a Gray bit width. Use the output as the exact non-negative integer's minimal Gray representation.
Related converters
Continue with exact representation converters
Use one canonical page for the precise input and output direction you need.