Hamming Code Calculator (Encode, Decode, Correct)
Encode data bits with a Hamming code — (7,4), (15,11) or any length, even or odd parity, optional SECDED bit — or decode a word: syndrome, error bit, fix.
Positions are numbered from 1 on the left; parity bits sit at 1, 2, 4, 8 …, and parity bit P covers every position whose number has that bit set.
| Parity bit | Position | Covers positions | Bits there | Check |
|---|---|---|---|---|
| P1 | 1 | 1, 3, 5, 7 | 0101 | holds |
| P2 | 2 | 2, 3, 6, 7 | 1111 | holds |
| P4 | 4 | 4, 5, 6, 7 | 0011 | holds |
| Position | Binary | Role | Bit |
|---|---|---|---|
| 1 | 001 | P1 | 0 |
| 2 | 010 | P2 | 1 |
| 3 | 011 | D1 | 1 |
| 4 | 100 | P4 | 0 |
| 5 | 101 | D2 | 0 |
| 6 | 110 | D3 | 1 |
| 7 | 111 | D4 | 1 |
A Hamming code adds a few parity bits to a block of data so that any single flipped bit can be found and corrected. It is the textbook example of error-correcting codes and is still used in ECC memory (as the SECDED variant). This calculator encodes data bits into a codeword, or checks a received word: it computes the syndrome, tells you which bit is wrong, corrects it and extracts the data — with a table showing which positions each parity bit covers.
How to use this tool
- Choose Encode or Check.
- Type the data bits (to encode) or the received word (to check).
- Pick the code size — or let the tool fit it to the length — and even or odd parity.
- Add the overall parity bit for SECDED if you need to detect double errors.
Formula
parity bit at position 2ᵗ = XOR of all positions with bit t set · syndrome = XOR of the positions of all 1 bits = position of the error
With r parity bits a codeword has n = 2ʳ − 1 positions and carries n − r data bits — (7,4), (15,11), (31,26); for other lengths the smallest r with 2ʳ ≥ k + r + 1 is used. Positions are numbered from 1 on the left and the data bits fill the positions that are not powers of two, in order. With odd parity every check is inverted. SECDED adds one bit with the parity of the whole word: a non-zero syndrome with failing overall parity is a correctable single error; a non-zero syndrome with overall parity intact means two errors.
Example
Encoding 1011 with Hamming(7,4): the data goes to positions 3, 5, 6 and 7; P1 = 1⊕0⊕1 = 0, P2 = 1⊕1⊕1 = 1 and P4 = 0⊕1⊕1 = 0, giving 0110011. If bit 5 flips (0110111), the 1 bits sit at positions 2, 3, 5, 6, 7 and 2⊕3⊕5⊕6⊕7 = 5, so bit 5 is corrected and the data 1011 is recovered.
Frequently asked questions
Can a Hamming code correct two errors?
No. The basic code corrects one error; with two errors the syndrome points to a wrong position. The extended (SECDED) code adds a bit so that two errors are at least detected.
Why are parity bits at positions 1, 2, 4, 8?
Each of those positions has a single 1 in binary, so each parity bit covers a different binary digit of the position numbers. Adding up the failing checks spells out the error position in binary.
Even or odd parity?
Both work the same way; odd parity simply inverts every check. Textbooks normally use even parity.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/hamming-code-calculator/
Cite or embed this tool
kakaoCalc. (2026, November 8). Hamming Code Calculator (Encode, Decode, Correct). https://kakao.mobile/tools/hamming-code-calculator/
“Hamming Code Calculator (Encode, Decode, Correct).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/hamming-code-calculator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms