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.
Decision gist · record as of 2026-08-14
Yes. tldextract is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem that naive URL parsing cannot handle. Use it whenever you need to reliably extract domain components from URLs, especially if your URLs include multi-level suffixes or private domains. The only gotcha is that it fetches the PSL on first use by default; disable that in production with suffix_list_urls=().AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- 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.
- Low friction: pure Python wheel with only four runtime dependencies (idna, requests, requests-file, filelock).
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive and widely compatible; you can use this in commercial and proprietary projects with minimal restrictions beyond retaining the license notice.
last release 2026-08-08 (6 days) · last repo commit 2026-08-08 · 2,011 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 38,532,719 downloads/mo, #714 on PyPI
Alternatives
Verify before relying
pip install tldextract
import tldextract
result = tldextract.extract('http://forums.bbc.co.uk')
print(result.subdomain, result.domain, result.suffix)
# Output: forums bbc co.uk- Performance characteristics with very large URL batches or high-frequency extraction calls.
- Behavior when the Public Suffix List cache becomes corrupted or out of sync.
What it is and what it does
tldextract solves the problem that naive URL parsing (splitting on dots) fails for domains with multi-level public suffixes. For example, splitting 'forums.bbc.co.uk' on dots gives 'co' as the suffix, when the correct suffix is 'co.uk' and the domain is 'bbc'. tldextract uses the Public Suffix List (PSL)—the same list browsers use for cookie scoping—to identify the true public suffix boundary, then separates the URL into subdomain, domain, and suffix components.
The library is lenient by design: it accepts any string (not just valid URLs) and returns an ExtractResult with subdomain, domain, suffix, and is_private fields. It caches the PSL locally by default but can be configured to use a custom or local suffix list, include private domains as suffixes, or add extra suffixes. It does not validate or canonicalize hostnames, so callers must normalize IDNA representations before using results in security decisions.
Use it for
- Extract the registrable domain from a URL to group cookies or analytics by organization rather than subdomain.
- Identify whether a hostname belongs to a known private domain provider (e.g., blogspot.com) for security or access-control decisions.
- Parse email addresses or hostnames in bulk to separate organizational domain from subdomains for data classification.
- Validate that a URL's suffix matches an allowlist of acceptable public suffixes before processing.
- Build a domain-based firewall or URL filter that treats all subdomains of a domain as a single unit.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
tldextract is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem that naive URL parsing cannot handle. Use it whenever you need to reliably extract domain components from URLs, especially if your URLs include multi-level suffixes or private domains. The only gotcha is that it fetches the PSL on first use by default; disable that in production with suffix_list_urls=().
Install
tldextract on PyPI
Before you install
Low friction: pure Python wheel with only four runtime dependencies (idna, requests, requests-file, filelock). Actively maintained with a release 6 days ago and 2011 repository stars. Supports current Python versions (3.10–3.14).
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.
License in practice
BSD-3-Clause is permissive and widely compatible; you can use this in commercial and proprietary projects with minimal restrictions beyond retaining the license notice.
Quickstart
pip install tldextract
import tldextract
result = tldextract.extract('http://forums.bbc.co.uk')
print(result.subdomain, result.domain, result.suffix)
# Output: forums bbc co.uk
Verify before relying
- Performance characteristics with very large URL batches or high-frequency extraction calls.
- Behavior when the Public Suffix List cache becomes corrupted or out of sync.
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 packagesidnarequestsrequests-filefilelock |
| Maintenance | Actively maintained 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 38,532,719 / month, #714 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | 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 |
Evidence: tldextract-5.3.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “url domain extraction”
- tldextractAccurately extracts subdomain, domain, and public suffix from URLs…
- ada-urlParse, validate, and manipulate URLs according to the WHATWG URL…
- tldExtracts the top-level domain (TLD) and first-level domain (FLD) from…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also tld · tldparse · tlds · urlextract · publicsuffix2 · publicsuffixlist · dnstwist · pyfaup-rs · python-whois · cleanco