EN
My tools

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.

Action
Codeword
0110011
Hamming(7,4), even parity
Parity bits
3
Code rate
57.14%
data bits ÷ all bits

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 checks
Parity bitPositionCovers positionsBits thereCheck
P111, 3, 5, 70101holds
P222, 3, 6, 71111holds
P444, 5, 6, 70011holds
Bit positions
PositionBinaryRoleBit
1001P10
2010P21
3011D11
4100P40
5101D20
6110D31
7111D41
My tools →
Advertisement

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

  1. Choose Encode or Check.
  2. Type the data bits (to encode) or the received word (to check).
  3. Pick the code size — or let the tool fit it to the length — and even or odd parity.
  4. 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:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). Hamming Code Calculator (Encode, Decode, Correct). https://kakao.mobile/tools/hamming-code-calculator/

MLA

“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

Advertisement