Home Tools Blog About

Binary to Gray Code Converter

In short

Convert binary to Gray code (BRGC) - XOR algorithm, bit-width preserved, step-by-step display, BigInt. Free, client-side, instant, offline, secure.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Transform binary numbers into their Binary Reflected Gray Code (BRGC) equivalent. Uses the canonical XOR formula g = b ^ (b >> 1). Preserves bit width, verifies the single-bit-change property on consecutive inputs, handles arbitrary widths via BigInt.

🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Binary to Gray Code Converter

  1. Paste binary values, one per line. All 0s and 1s. Leading zeros matter - they define the bit width. 0011 is 4-bit; 11 is 2-bit. The output preserves your input width.
  2. Pick an output format. Plain shows just the Gray code. Compare shows binary → gray side by side (handy for verifying by eye). Bit groups inserts a space every 4 bits on the output, helpful for long bit widths.
  3. Enable “Show XOR steps” for a per-bit breakdown of the first valid line. Each bit g[i] = b[i] XOR b[i-1] (except g[0] = b[0]) is listed so you can verify the algorithm by hand.
  4. Watch for the Gray-code property confirmation. If you enter sequential binary values (0000, 0001, 0010, 0011...), the stats line should say ✓ sequential Δ=1 (true Gray code) - each output differs from the previous by exactly one bit, which is Gray code’s defining property.
  5. Check the stats. Total lines · total input bits · validity · delta range (if applicable). Invalid lines show inline ERROR: with the bad char and its position.
  6. Copy or download. Output goes to clipboard or saves as gray-code-<timestamp>.txt. Ctrl+Enter / Cmd+Enter runs convert + copy.
  7. Cross-check by reversing. Feed Gray codes into our Gray-code-to-binary tool (sibling page) to verify the round-trip preserves your original values.

Frequently Asked Questions

What is Gray code?

Gray code is a binary numeral system where two consecutive values differ by only one bit. It is used in rotary encoders, error correction, and digital communications to prevent glitches during transitions.

How does the XOR algorithm work?

Gray code is produced by XORing each bit with its more-significant neighbor. The most-significant bit stays the same, and each subsequent bit is original XOR previous-original.

Why preserve bit width?

Gray code operations often rely on fixed-width values (e.g., 8-bit rotary encoders). The tool pads the input with leading zeros to preserve your chosen width so the output is directly usable.

Does it show the algorithm step by step?

Yes. Step-by-step mode displays each XOR operation with both input bits and the resulting Gray code bit, making it useful for students and for verifying hand calculations.

Where is Gray code used in real systems?

Rotary encoders, Karnaugh maps, digital communication error detection, analog-to-digital converters, and some hardware state machines.

Is my data secure?

Yes. Conversion runs entirely in your browser. Nothing is uploaded or logged.

Is this tool free?

Yes, completely free with no account needed.

What if my input has invalid characters?

The tool checks the input and reports any non-binary characters so you can correct them before converting.

Can I reverse the conversion?

Yes. A complementary Gray code to binary tool is available for the inverse operation.

How large can my binary input be?

The tool supports inputs up to thousands of bits using JavaScript BigInt, so practical lengths (32-bit, 64-bit, or larger) work without precision loss.

Keep going

Related Tools

All Binary tools →

Convert Gray Code to Binary

Decode Gray code (reflected binary) to standard binary, decimal, or hex. BigInt-safe, per-line errors,…

Convert Decimal to Gray Code

online decimal to Gray code (reflected binary) converter with bit-width, grouping, and step-by-step XOR…

Convert Gray Code to Decimal

Decode Gray code (reflected binary) to decimal, binary, or hex using BigInt. Per-line errors,…

Convert Gray Code to Hexadecimal

Decode binary Gray code bits into hexadecimal, decimal, or standard binary. BigInt-safe, per-line errors,…

Convert Gray Code to Octal

Decode Gray code (reflected binary) to octal, decimal, binary, or hex. BigInt-safe, per-line errors,…

Convert Hexadecimal to Gray Code

Convert hex to Gray code. Free, secure, instant, 100% client-side processing.

Convert Octal to Gray Code

Convert octal to Gray code (and back) with XOR derivation and transition preview. Bit…

Calculate Bitwise AND of Binary Values

Calculate Binary Values Online Free - Fast and accurate binary computations for developers, students,…

Binary to Decimal Converter

Convert extremely large machine binary strings natively into format decimal bounds infinitely fast offline…

Calculate Binary Addition

Calculate Binary Addition numbers with carry visualization and multi-format output. Free, offline, client-side, instant…

Binary to Image Converter

Render binary as a pixel image - multiple color schemes, pixel scaling, PNG export,…

Binary to IP Converter

Convert 32-bit binary to IPv4 or 128-bit binary to IPv6 - with classification, canonical…

Share

Embed this tool

Add this free tool to your website. Copy and paste the code: