skillfed

textdistance

Compute distance between the two texts.

textdistance v4.6.3 2.6M downloads/30d#2,991 on PyPI3,538
Permissive license MIT AGING released

What it is and what it does

TextDistance is a pure-Python library that implements a large collection of algorithms for measuring how different two or more text sequences are from each other. It provides both distance metrics (how far apart sequences are) and similarity metrics (how alike they are), with support for edit-based algorithms like Levenshtein and Damerau-Levenshtein, token-based methods like Jaccard and Cosine similarity, sequence-based approaches like longest common subsequence, compression-based distance, and phonetic matching. The library has zero runtime dependencies by default and offers optional numpy integration for speed on specific algorithms.

You use it by instantiating an algorithm class or calling a function directly, then invoking methods like `.distance()`, `.similarity()`, or `.normalized_distance()` to compare sequences. It's designed for straightforward use cases where you need to measure text similarity—fuzzy matching, deduplication, spell-checking support, or record linkage—without needing to implement these algorithms yourself.

Use it for:

  • Fuzzy string matching to find similar product names or user entries despite typos or variations
  • Deduplication of text records by computing similarity scores between candidates
  • Spell-checking or autocorrect by ranking candidate corrections by edit distance
  • Record linkage in data integration by comparing field values across datasets
  • Phonetic matching for names that sound similar but are spelled differently

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes distance and similarity between text sequences using 30+ algorithms including Levenshtein, Jaro-Winkler, Hamming, and compression-based methods.

Yes. The package is stable, permissively licensed, has no dependencies, and provides a comprehensive toolkit for a common task. The aging maintenance status (last release 759 days ago) is a minor concern but not a blocker—the library solves a well-defined problem with established algorithms, and the repository remains active and not archived. Install it if you need string distance or similarity computation.

Install

textdistance on PyPI

pip

pip install textdistance

uv

uv add textdistance

poetry

poetry add textdistance

Installing textdistance

Before you install

Low friction installation with no runtime dependencies. Maintenance status is aging—last release was 2024-07-16, with 759 days since then—but the package remains in production/stable state with an active repository (3538 stars, not archived).

License in practice

MIT license (permissive) means you can use this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install textdistance

from textdistance import Levenshtein

levenshtein = Levenshtein()
distance = levenshtein.distance('kitten', 'sitting')
print(distance)  # 3

Verify before relying

  • Whether optional numpy integration actually improves performance for the algorithms listed, and which ones benefit most
  • Current state of the 'work in progress' compression-based algorithms (BZ2NCD, LZMANCD, ZLIBNCD) and whether they are production-ready

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 759 days since the last release
Last repo commit
First released
Downloads 2,580,088/month — #2,991 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: textdistance-4.6.3-py3-none-any.whl

Keywords: distance, between, text, strings, sequences, iterators

Development Status :: 5 - Production/StableEnvironment :: PluginsIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonTopic :: Scientific/Engineering :: Human Machine Interfaces

Tags

string similarity distancelevenshtein distance pythontext sequence comparisonjaro-winkler implementationedit distance algorithmsfuzzy string matchingsequence alignment
string-similaritysequence-alignmentfuzzy-matching

More Human Machine Interfaces packages