Linkify-it-py: Unicode-aware Link Recognition
Linkify-it-py is a Python port of the popular JavaScript library 'linkify-it', designed for robust links recognition with full Unicode support. It excels at high-quality link pattern detection in plain text, accommodating international domains and astral characters. The library provides flexibility for extending its rules and implementing custom normalizers. As of March 2026, the current stable version is 2.1.0, and it maintains an active release cadence.
Warnings
- breaking Version 2.0.0 introduced significant changes, including the addition of `matchAtStart` and fixes for paired symbols. While not all API changes were explicitly marked as breaking in `linkify-it-py`'s changelog, a major version bump indicates potential behavioral shifts that may affect applications relying on specific older parsing behaviors. Reviewing release notes is advised for upgrades from `v1.x.x`.
- gotcha The library explicitly requires Python 3.10 or higher. Attempting to install or run `linkify-it-py` on older Python versions (e.g., 3.9 or earlier) will result in installation failures or runtime errors due to `Requires-Python` metadata.
- gotcha By default, `LinkifyIt()` is initialized with predefined schemas for `http(s)://`, `ftp://`, `mailto:`, `//` (protocol-neutral), as well as 'fuzzy' links (like `example.com`) and email addresses. Users sometimes mistakenly try to re-add these default schemas, which is unnecessary and can lead to unexpected behavior if custom rules conflict.
Install
-
pip install linkify-it-py
Imports
- LinkifyIt
from linkify_it import LinkifyIt
Quickstart
from linkify_it import LinkifyIt
# Initialize linkifier with default schemas (http, https, ftp, mailto, fuzzy links)
linkify = LinkifyIt()
text1 = "Visit our site: github.com!"
matches1 = linkify.match(text1)
print(f"Text: '{text1}'")
for match in matches1:
print(f" Matched: '{match.raw}' at index {match.index}-{match.last_index}, URL: {match.url}")
text2 = "Email me at user@example.com or check //example.net/path"
matches2 = linkify.match(text2)
print(f"\nText: '{text2}'")
for match in matches2:
print(f" Matched: '{match.raw}' at index {match.index}-{match.last_index}, URL: {match.url}")
# Example with custom options
from linkify_it.tlds import TLDS
linkify_custom = (
LinkifyIt()
.tlds(TLDS) # Reload with full official TLDs list
.tlds("onion", True) # Add unofficial .onion domain
.add("git:", "http:") # Treat 'git:' as an alias for 'http:'
.set({"fuzzy_ip": True}) # Enable IPs in fuzzy links (without schema)
)
text3 = "Check out git:repo.git or a fuzzy IP 192.168.1.1/admin"
matches3 = linkify_custom.match(text3)
print(f"\nText: '{text3}' (custom linkify)")
for match in matches3:
print(f" Matched: '{match.raw}' at index {match.index}-{match.last_index}, URL: {match.url}")