Count the differing positions between two equal-length inputs, in characters, binary bits or integer XOR, all in your browser
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
3 positions
Aligned positions (differences highlighted)
What this tool does
A Hamming distance calculator that counts how many positions two equal-length inputs differ in. Unlike edit distance, Hamming never inserts or deletes; it simply walks both inputs position by position and tallies the mismatches, which is why the two sides must be the same length. Three modes cover the common cases. Character mode compares text by Unicode code point, so emoji and CJK characters each count as one symbol. Binary mode compares two bit strings digit by digit, ignoring spaces so 1011 0010 and 10110010 read the same. Integer mode takes two whole numbers, XORs them and counts the set bits using BigInt, so the answer stays exact even for numbers far past 64 bits and never depends on how many leading zeros you imagine. Differing positions are highlighted side by side, the result copies in one click, and the share link reproduces both inputs and the mode. Everything runs as plain JavaScript in your tab. No upload, no account, no rate limit.
Tool details
- Input
- Numbers
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How Hamming Distance Calculator fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 Text Sorter Sort lines alphabetically, numerically, by length, or reverse — case-sensitive optional — browser-only Open
- 2 Regex Tester Test JavaScript regex live — match highlighting, group capture, replace preview, flag toggles — browser-only Open
- 3 String Similarity Checker Levenshtein edit distance, Dice, Jaro-Winkler and LCS side by side, with a 0-100% match score, all in your browser Open
Real-world use cases
Check error-correcting code coverage
You are designing a fixed-width code and need to know how many bit errors it can survive. Enter two valid codewords in binary mode and read their distance; the minimum distance across all pairs tells you the guarantee. A minimum distance of 3 detects two bit flips and corrects one, so if any pair you test comes back as 2, that pair is too close and the code will not correct a single-bit error between them.
Compare two perceptual hashes for duplicate images
Two photos produced 64-bit pHashes and you want to know if they are near-duplicates. Paste both hashes as integers, switch to integer mode, and read the bit distance from the XOR. A distance under about 10 out of 64 usually means the same image at a different size or compression, while a large distance means genuinely different pictures. The BigInt math keeps the full 64 bits exact.
Spot a single-bit flip in transmitted data
A register or packet came back different from what you sent and you suspect line noise rather than a logic bug. Put the expected and received values side by side in binary mode; a distance of exactly 1 points to a single bit flip at a specific position, which the highlighted aligned view pinpoints for you. A larger distance suggests a framing or addressing problem instead.
Teach or check a coding-theory homework problem
A student is learning Hamming codes and needs to verify distances by hand. Enter the two binary strings, confirm the count, and use the highlighted positions to see exactly which bits the textbook answer is counting. Share the URL with a classmate and the same two inputs and mode open for them, so a study group can check each other without re-typing.
Common pitfalls
Feeding two inputs of different lengths. Hamming distance is only defined when both sides have the same number of positions; there is no insert or delete to absorb the gap. If you need to compare strings that can differ in length, use edit distance (Levenshtein) instead, which this tool links to.
Confusing Hamming distance with edit distance. They agree only when no insertions or deletions are involved. For abc versus acb, Hamming counts 2 substitutions while edit distance is also 2, but for off-by-one shifts they diverge sharply, so do not quote one number when you mean the other.
Padding integers to different widths and expecting a different answer. In integer mode the result is popcount of the XOR, which already ignores leading zeros, so 0001 versus 0010 and 1 versus 2 give the same distance of 2. Do not hand-pad before entering; just type the plain numbers.
Privacy
Every step runs as plain JavaScript in your browser tab: the position comparison, the binary diff, and the BigInt XOR popcount. Neither input is ever uploaded, and nothing about what you compared is logged. The one caveat: the share link encodes both inputs and the mode in the URL query string, so a link pasted into chat will record those values in the recipient server's access log. For confidential codes, hashes or identifiers, use the copy button and paste the result instead of sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only