Gray Code Converter and Generator

Generate the n-bit Gray code sequence and convert a number to Gray code and back.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Gray Code Converter and Generator and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Gray Code Converter and Generator does

    Generate the n-bit Gray code sequence and convert a number to Gray code and back.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter the number of bits (1 to 16) and optionally a decimal value. The calculator lists the binary and Gray code for each number (the first 64 for longer codes) and converts your value in both directions.

Definition

In Gray code consecutive values differ in exactly one bit. The Gray code of n is n XOR (n >> 1), and the binary is recovered by XOR-ing all the right shifts of the Gray code.

Uses

Rotary encoders, Karnaugh maps and error-minimising counters use Gray code because only one bit changes at a time.

Worked example

With 4 bits, 10 (1010) has the Gray code 1111. Reading 1010 as Gray code gives the binary value 12.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

How is Gray code made?

XOR the number with itself shifted right by one bit.

Is it unique?

This is the standard reflected binary Gray code.

What is Gray to binary?

XOR together the code and all its right shifts.

Why only 64 rows?

Longer lists are cut to keep the page readable; the conversion still works.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages