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.
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).
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).
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.
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.
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.
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.