Search for a tool
Hamming Distance

Tool to calculate the Hamming distance between two strings of the same length, compare binary or textual words and measure their similarity in seconds.

Results

Hamming Distance -

Tag(s) : Informatics, Data Processing

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Hamming Distance' tool for free! Thank you!

Hamming Distance

Hamming Distance Calculator


Loading...
(if this message do not disappear, try to refresh this page)

Loading...
(if this message do not disappear, try to refresh this page)




Hamming Code Calculator

Answers to Questions (FAQ)

What is the Hamming distance? (Definition)

The Hamming distance between two words of the same length, $ n $, is the number of positions at which the corresponding symbols differ. It measures the dissimilarity between two words.

Formally, for two words $ x = (x_1, \dots, x_n) $ and $ y = (y_1, \dots, y_n) $, the Hamming distance is: $$ \operatorname{Hamming}(x,y) = \sum_{i=1}^{n} \mathbf{1}_{x_i \neq y_i} $$

How do you calculate the Hamming distance between two binary numbers?

To calculate the Hamming distance between two binary numbers of the same length: compare the bits position by position and count the number of positions where the bits differ.

Example: 10011 and 10101 differ in positions 3 and 4, so the Hamming distance is equal to 2

How to calculate the Hamming distance for words?

The generalized Hamming distance can be applied to any string of characters. It counts the number of positions where symbols differ.

Example: DECODE and ENCODE have a Hamming distance of 2 characters.

What is the purpose of the Hamming distance?

The Hamming distance measures how different two words of the same length are. It is used to:

— compare two strings or sequences of symbols

— quantify the error between expected and observed data

— measure the similarity between two discrete objects

The smaller the distance, the more similar the two words are. If the distance is zero, the two words are identical.

The distance is undefined if the words do not have the same length

What is the Hamming code?

Several codes are based on the Hamming distance, such as the Hamming (7,4) code: 4 data bits, 3 parity bits, or the extended Hamming (8,4) code: 4 data bits, 4 parity bits.

Source code

dCode retains ownership of the "Hamming Distance" source code. Any algorithm for the "Hamming Distance" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Hamming Distance" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Hamming Distance" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "Hamming Distance" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/hamming-distance

In a scientific article or book, the recommended bibliographic citation is: Hamming Distance on dCode.fr [online website], retrieved on 2026-03-24, https://www.dcode.fr/hamming-distance

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Hamming Distance' tool for free! Thank you!


https://www.dcode.fr/hamming-distance
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
â–˛  
Feedback