Free binary error-correction tool

Hamming Code Calculator

Encode binary data with Hamming parity bits, inspect parity groups, and decode received codewords to find and correct single-bit errors. Use standard Hamming(7,4) or extended Hamming(8,4) with SECDED error detection.

Encode, decode and correct binary data

Choose an operation, enter your bits, and calculate the result. All calculations run locally in your browser.

Three parity bits are inserted at positions 1, 2 and 4.

Enter four bits, such as 1011. Spaces are allowed.

Encoded codeword
0110011

Bit positions

Original / recovered data 1011
Parity bits p1=0, p2=1, p4=0
Syndrome 000
Error status No error detected

Calculation steps

    How Hamming(7,4) works

    Hamming(7,4) takes four data bits and adds three parity bits, creating a seven-bit codeword. Number the positions from left to right, starting at 1. The parity bits occupy positions 1, 2 and 4, while the data bits occupy positions 3, 5, 6 and 7.

    PositionRoleParity coverage
    1p11, 3, 5, 7
    2p22, 3, 6, 7
    3d1Checked by p1 and p2
    4p44, 5, 6, 7
    5d2Checked by p1 and p4
    6d3Checked by p2 and p4
    7d4Checked by p1, p2 and p4

    Parity equations for even parity

    p1 = d1 XOR d2 XOR d4

    p2 = d1 XOR d3 XOR d4

    p4 = d2 XOR d3 XOR d4

    XOR returns 1 when an odd number of input bits are 1. Each parity bit is chosen so the total number of ones in its covered group is even. For odd parity, the parity bit is inverted so that each group has an odd number of ones.

    Worked example: data 1011

    For data bits d1=1, d2=0, d3=1 and d4=1:

    • p1 = 1 XOR 0 XOR 1 = 0
    • p2 = 1 XOR 1 XOR 1 = 1
    • p4 = 0 XOR 1 XOR 1 = 0

    The resulting even-parity codeword is 0110011, arranged as p1, p2, d1, p4, d2, d3, d4.

    How error detection and correction work

    A receiver recalculates the parity checks for the received codeword. Each failed check contributes its parity position to a syndrome. For Hamming(7,4), the syndrome is formed from the p4, p2 and p1 check results.

    • Syndrome 000: all three parity checks pass.
    • Non-zero syndrome: under the single-bit-error assumption, its binary value identifies the bit position to flip.
    • After correction: the calculator displays the corrected codeword and extracts the four data bits.

    For example, if the codeword 0110011 is received as 0100011, position 3 has changed. The syndrome identifies position 3, allowing the decoder to flip it back.

    What is extended Hamming(8,4)?

    Extended Hamming(8,4) adds an overall parity bit at position 8. This creates a SECDED code: single-error correction and double-error detection. The three Hamming checks locate a possible error among positions 1–7, while the overall parity check helps distinguish a single-bit error from a two-bit error.

    Important: ordinary Hamming(7,4) is designed to correct one flipped bit. Multiple-bit errors can produce misleading syndromes. Extended Hamming(8,4) can correct a single-bit error and detect a double-bit error under the standard SECDED assumptions, but it cannot correct two flipped bits.

    Frequently asked questions

    What is a Hamming code?

    A Hamming code adds parity bits to binary data so a receiver can identify and correct a single-bit error. The classic Hamming(7,4) code converts four data bits into a seven-bit codeword using three parity bits.

    What does Hamming(7,4) mean?

    The first number represents the seven total codeword bits, and the second represents the four data bits. The remaining three bits are parity bits used for error detection and single-bit correction.

    Where are the Hamming parity bits placed?

    In the standard seven-bit layout, parity bits are placed at positions 1, 2 and 4, which are powers of two. The data bits occupy positions 3, 5, 6 and 7.

    Can Hamming(7,4) correct two errors?

    No. Standard Hamming(7,4) corrects one bit error. Two flipped bits may generate a syndrome that looks like a single-bit error, so the decoder can change the wrong bit. Extended Hamming adds an overall parity bit to support single-error correction and double-error detection.

    What is a syndrome in error correction?

    A syndrome is the pattern of failed parity checks. In standard Hamming(7,4), the three check bits form a binary number that identifies the affected position when there is exactly one flipped bit.

    What is the difference between even and odd parity?

    Even parity makes each checked group contain an even number of ones. Odd parity makes each checked group contain an odd number of ones. The sender and receiver must use the same convention.

    Related binary tools