Calculators

Hamming Distance Calculator

Count differing positions in two equal-length strings and calculate normalized distance privately in your browser.

Enter two nonempty strings of equal Unicode code point length. Matching is case-sensitive; spaces, punctuation and newlines count. No trimming or Unicode normalization is applied. Each field allows up to 200000 UTF-16 code units. All calculation runs locally in your browser.

Your Hamming distance will appear here.

How Hamming distance works

Hamming distance counts positions with different characters in equal-length strings. For karolin and kathrin, three of seven positions differ, so the distance is 3, normalized distance is 3/7, and matching percentage is 4/7 × 100. Identical nonempty strings have distance 0; strings differing at every position have normalized distance 1. Unlike set similarity, character order and repeated characters matter. Unlike edit distance, this calculation does not allow insertions or deletions. Binary strings are compared as characters, not converted to numbers. Comparison uses Unicode code points: an emoji may be one code point or a sequence of several, and combining marks count separately. No Unicode normalization, case folding or whitespace trimming is performed. Both fields must be nonempty and contain equal numbers of code points. Each input is limited to 200000 UTF-16 code units. Processing and copy controls run in your browser.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

How is Hamming distance calculated?

Count unequal positions in two equal-length strings. For karolin and kathrin the distance is 3. Divide by the string length for normalized distance.

Can I compare different-length strings?

No. Hamming distance requires equal lengths. Insertions and deletions require an edit-distance measure instead.

How are Unicode and whitespace handled?

The calculator compares Unicode code points, case-sensitively. Spaces and newlines count. Combining marks and multi-code-point emoji may occupy multiple positions. No trimming or Unicode normalization is applied.

Can I compare binary strings?

Yes. For 1011 and 1001, one position differs, giving distance 1. Binary digits are compared as characters; other text is also accepted.

What limits and privacy rules apply?

Both inputs must be nonempty, have equal code point lengths, and contain at most 200000 UTF-16 code units each. Inputs remain in your browser; matching percentages display up to 12 significant digits.