Linkify-it-py: Unicode-aware Link Recognition

2.1.0 · active · verified Sun Mar 29

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

Install

Imports

Quickstart

This quickstart demonstrates basic linkification using `LinkifyIt` with default settings, showing how to test for and extract link matches. It also includes an example of customizing the linkifier by adding TLDs, protocol aliases, and enabling fuzzy IP detection.

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}")

view raw JSON →