Fuzzy Matching for SEO in Python: Scorers, Redirects and Library Comparison
Fuzzy matching scores how similar two strings are, which makes it the quiet workhorse behind redirect maps, duplicate checks and “have we already written this?” questions. This free Google Colab notebook recreates every tab of my free Fuzzy Matching for SEO Google Sheets template in Python, then goes further: it compares the main libraries and shows where character-level matching stops being the right tool.
Who it’s for
SEOs who have outgrown the Sheets version, and anyone who wants to understand what ratio, partial_ratio and token_set_ratio actually measure before trusting a score. You need basic comfort running cells in Colab. No API keys are needed. If you already use the Sheets template, this is the natural next step when your lists grow beyond what spreadsheet formulas handle comfortably, since RapidFuzz can compare whole lists of strings in one call.
How to use it
- Open the notebook in Colab and run all cells. Every section runs on built-in sample data first.
- Start with Scorers 101 to see how each scorer, raw Levenshtein distance and Jaro-Winkler treat the same pairs.
- Replace the lists marked
# YOUR DATAwith your own keywords, titles or URLs. - Run the string assessment for duplicate checks and the redirect mapping section for old-to-new URLs.
- Add a Screaming Frog inlinks export to the internal linking section to see which suggested links already exist.
- Export the CSVs.
What you get
- The nearest neighbour for every keyword or title in a list, for duplicate and keyword cannibalisation checks
- A redirect map with direct, partial and no-match buckets
- Internal linking candidates per page, checked against the links you already have
- A side-by-side of RapidFuzz, TheFuzz (the renamed FuzzyWuzzy) and PolyFuzz, plus a pandas replacement for the unmaintained fuzzy-pandas
- Phonetic matching with Metaphone and NYSIIS, and a worked example of why character similarity misfires for keyword clustering
Limits
Fuzzy matching compares characters, so “cheap flights” and “budget airfare” score low even though they mean the same thing. For meaning, the notebook includes an optional embeddings comparison through PolyFuzz. It is switched off by default and downloads a model when you turn it on. Library versions move quickly: the README lists exactly what was tested in October 2026, and which libraries are still maintained.
The full explanation is in What Fuzzy Matching Is, and Where It Fits in SEO. To learn fuzzy matching alongside clustering, classification and entity analysis, with guided practicals, see Introduction to Machine Learning for SEO.
What’s included
- Every tab of the free Fuzzy Matching for SEO Sheets template, recreated in Python
- Scorers explained side by side: ratio, partial, token sort, token set, WRatio, Levenshtein, Jaro-Winkler
- Duplicate and cannibalisation checks, redirect mapping and internal link candidates
- RapidFuzz vs TheFuzz vs PolyFuzz, plus phonetic matching with Metaphone and NYSIIS
- Runs on built-in sample data with no API keys
Where this resource is used on MLforSEO
Walkthroughs on the blog
Concepts behind it
More site migrations resources
- No-Code TemplateFuzzy Matching for SEO Use Cases (Google Sheets Template)
- GuideComprehensive String Matching & Fuzzy Matching Reference Guide for SEO Applications: Use Cases, Approaches, Models
- Coding Script or NotebookAutomated Redirect Mapping with Triple Fuzzy Matching for Site Migrations (Notebook)
- Coding Script or NotebookMapping 404 URLs to Live Pages with Fuzzy Matching (Guide)
- Coding Script or NotebookStatic Site Link Checks: Stop Broken Internal Links at Build Time (Hugo, Astro, Next.js and More)
- ChecklistSEO Site Migration Checklist + Redirect Mapping Workbook
See all 8 site migrations resources →See all 28 content audits resources →See all 73 coding script or notebook resources →
