skillfed

tldextract

Accurately separates a URL's subdomain, domain, and public suffix, using the Public Suffix List (PSL). By default, this includes the public ICANN TLDs and their exceptions. You can optionally support the Public Suffix List's private domains as well.

tldextract Permissive license BSD-3-Clause Active 2,011 v5.3.2 released

Install

tldextract on PyPI

pip

pip install tldextract

uv

uv add tldextract

poetry

poetry add tldextract

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 4 — idna, requests, requests-file, filelock
Maintenance actively maintained — 5 days since the last release
Last repo commit
First released
Popularity one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13)
Known vulnerabilities none known (OSV.dev, checked 2026-08-13)

Evidence: tldextract-5.3.2-py3-none-any.whl

Keywords: tld, domain, subdomain, url, parse, extract, urlparse, urlsplit, public, suffix, list, publicsuffix, publicsuffixlist

Development Status :: 5 - Production/StableProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Utilities

About tldextract

from the package's own PyPI description — quoted content, verbatim

tldextract PyPI version (image) Build Status (image)

tldextract accurately separates a URL's subdomain, domain, and public suffix, using the Public Suffix List (PSL).

Why? Naive URL parsing like splitting on dots fails for domains like forums.bbc.co.uk (gives "co" instead of "bbc"). tldextract handles the edge cases, so you don't have to.

Quick Start

>>> import tldextract

>>> tldextract.extract('http://forums.news.cnn.com/')
ExtractResult(subdomain='forums.news', domain='cnn', suffix='com', is_private=False)

>>> tldextract.extract('http://forums.bbc.co.uk/')
ExtractResult(subdomain='forums', domain='bbc', suffix='co.uk', is_private=False)

>>> # Access the parts you need
>>> ext = tldextract.extract('http://forums.bbc.co.uk')
>>> ext.domain
'bbc'
>>> ext.top_domain_under_public_suffix
'bbc.co.uk'
>>> ext.fqdn
'forums.bbc.co.uk'

Install

pip install tldextract

How-to Guides

...

Read as markdown · JSON record · Source repository · Homepage

AI interpretation — verify before relying

AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page

tldextract accurately parses URLs to separate subdomains, domains, and public suffixes using the Public Suffix List, handling edge cases like multi-level suffixes (e.g., co.uk) that naive dot-splitting would misparse.

Low friction: pure Python wheel with four lightweight runtime dependencies (idna, requests, requests-file, filelock). Active maintenance with a release 5 days ago and 2011 GitHub stars; supports Python 3.10–3.14.

BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; attribution and license notice required in distributions.

Usage

pip install tldextract

import tldextract
result = tldextract.extract('http://forums.bbc.co.uk/')
print(result.domain, result.suffix)  # Output: bbc co.uk

Requires Python ≥3.10. By default, fetches and caches the Public Suffix List on first use; set suffix_list_urls=() to disable network access in production.

Verdict: tldextract is a mature, actively maintained library (Production/Stable since 2011) that solves a real URL-parsing problem with the Public Suffix List standard. No known vulnerabilities, permissive license, and low install friction make it a safe choice for domain extraction tasks.

Needs verification

  • Whether the default PSL fetch behavior requires internet connectivity at runtime or only at first initialization.
  • Performance characteristics when processing high volumes of URLs or with very large custom suffix lists.
url domain extractionparse subdomain and tldpublic suffix list parserdomain name parsingtld extraction from urlurl component separationfqdn parsing

Similar packages