AI Security

Hamming Distance Calculator

Calculate the Hamming distance between two equal-length strings or binary numbers, the number of positions at which they differ.

Last reviewed by the Radiatus Cloud team

Calculate the Hamming distance between two equal-length strings.

Securing AI in production?

We build guardrails, governance & compliance for AI systems.

Talk to an AI advisor

Calculate Hamming distance

The Hamming distance between two equal-length strings is the number of positions at which the corresponding characters differ. This calculator counts those positions for any pair of equal-length strings, whether text, binary numbers or codes. For the words karolin and kathrin, the characters differ in three positions, so the Hamming distance is three. Unlike edit distance, it compares strictly position by position and so requires the two strings to be the same length.

It also reports the number of matching positions and a similarity percentage.

Where Hamming distance matters

Hamming distance is fundamental to error-detecting and error-correcting codes, where it measures how many bit errors separate two codewords and therefore how many errors a code can detect or correct. It is also used in information theory, cryptography, and comparing fixed-length identifiers and hashes. Because it is so simple and fast, it is a natural choice whenever the inputs are guaranteed to be the same length.

For strings of different lengths, the Levenshtein edit distance is the appropriate measure instead. All calculation happens locally in your browser.

Notes on these estimates

Because the hamming distance calculator runs entirely in your browser, nothing you enter is uploaded, so you can use it with private data safely. The figures are estimates based on the values you provide and common rules of thumb, so treat them as planning guidance rather than exact measurements, and run the tool as often as you need for free.

Related tools

Frequently Asked Questions

What is Hamming distance?

It is the number of positions at which two equal-length strings have different characters, comparing them position by position.

Why must the strings be the same length?

Hamming distance compares characters at matching positions, so it is only defined for strings of equal length. Use Levenshtein for different lengths.

Where is it used?

In error-detecting and error-correcting codes, information theory, cryptography and comparing fixed-length identifiers and hashes.

Can I use it on binary numbers?

Yes. Entering two equal-length binary strings gives the number of differing bits, which is the Hamming distance between them.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Enter two equal-length strings or binary values.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.