Text & documents
Numbers & maths
Data & formats
Security
Development & DevOps
Artificial Intelligence
Finance
Health & Wellness
Productivity
Games & Entertainment
Multimedia & design
Business
How to use
What it is and what it's for

The Hamming code is an error-correcting code: it adds a few parity bits to your data so that, if a bit is corrupted during transmission or storage, it can be detected and corrected automatically without resending anything. It is used in ECC memory, communications and storage. A classic Hamming code corrects 1 wrong bit per word; with the SECDED extension it also detects 2. All the computation happens in your browser.

How to use it (the three tabs)

1. Encode — type your data bits and get the codeword with the parity already interleaved; click a bit to simulate an error.
2. Detect and correct — paste a codeword (with or without a fault) and you'll see the syndrome, the wrong bit and the corrected word.
3. Simulator — send the same word thousands of times over a noisy channel and measure how many are corrected, detected or fail.

The SECDED toggle and the Examples menu are on all three tabs. Everything recalculates by itself as you type (no button).

What to enter and its limits

In Encode there are two modes:
Bits — only 0 and 1 characters (the data, without parity bits: they are added for you).
Text — ASCII/Latin-1 text; each character is turned into 8 bits (characters outside that range are not accepted).

In Detect and correct you paste the full codeword (data + parity), also in 0 and 1. Any other character turns the field red. There is no length limit: the more data bits, the more efficient the code (less parity per bit).

How encoding works

Parity bits go in the power-of-two positions (1, 2, 4, 8, 16…) and data bits fill the rest. For k data bits, the code picks just enough r parity bits so that 2^r ≥ k + r + 1 (so 4 data → 3 parity = Hamming(7,4); 8 data → 4 parity).

Each parity bit Pi covers the positions whose index has that bit set: P1 (1, 3, 5, 7…), P2 (2, 3, 6, 7…), P4 (4, 5, 6, 7…). Its value is set (with XOR) so the number of ones it covers is even. The Coverage table shows which positions each one watches.

How it detects and corrects (the syndrome)

When the word arrives, each parity is rechecked with an XOR. The syndrome is the sum of the failing parity positions and, by the way they were placed, it equals exactly the position of the wrong bit: syndrome 0 = no error; syndrome 5 (= 101 in binary) = bit 5 is wrong, and it is flipped to correct it.

Careful: Hamming always assumes a single error. If 2 bits are wrong, the syndrome points at an innocent third bit and "corrects" it wrongly → silent failure (wrong data with no warning). That's what SECDED is for.

SECDED (extended parity)

Enabling SECDED adds a global parity bit (P0) covering the whole word, raising the minimum distance from 3 to 4. With that the code corrects 1 error and detects 2 (though it cannot correct double errors). It is what ECC memory uses.

The logic combines the syndrome with P0: syndrome 0 and P0 correct = no error; syndrome ≠ 0 and P0 fails = 1 correctable error; syndrome ≠ 0 but P0 correct = double error detected; only P0 fails = P0 itself got corrupted.

Simulate an error (Encode tab)

After encoding, click any bit of the word to "corrupt" it and watch instantly how the syndrome locates the flagged bit and corrects it. If you flip 2 or more bits you'll see the silent failure (or, with SECDED, the double-error detection). Use Restore word to go back to the original or Send to Detect and correct to analyze it in the other tab.

HammingError detection
Hamming CodeError detection and correction (with SECDED and simulator)
Data without parity bits (they are added automatically)