tld
Extract the top-level domain (TLD) from the URL given.
Decision gist · record as of 2026-08-14
Yes. tld is a stable, actively maintained utility with zero dependencies, broad Python version support, and no known vulnerabilities. Its copyleft license requires review if you distribute proprietary code, but the license terms are well-established. Install it for any project needing reliable URL-to-domain decomposition.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or greater; TLD names list should be updated via `update-tld-names` if domain recognition fails.
- Low friction: pure Python wheel with no runtime dependencies.
- Active maintenance with recent commits and stable production status across modern Python versions (3.9–3.15).
License · maintenance · safety
MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later (copyleft) — Copyleft license (MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later) requires derivative works to be distributed under compatible terms; review your project's license compatibility before use.
last release 2026-03-06 (161 days) · last repo commit 2026-05-07 · 186 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 15,866,317 downloads/mo, #1,171 on PyPI
Alternatives
Verify before relying
pip install tld
from tld import get_tld
get_tld("http://www.google.co.uk")
# 'co.uk'
get_tld("http://www.google.idontexist", fail_silently=True)
# None- Frequency and process for updating the Public Suffix list bundled with releases.
- Performance characteristics when parsing large batches of URLs.
- Whether custom parser implementations are commonly used in production.
What it is and what it does
tld is a lightweight URL parser that extracts domain components—top-level domain, first-level domain, subdomain, and full domain—from URLs using the Mozilla Public Suffix list. It handles edge cases like multi-part TLDs (e.g., 'co.uk') and can optionally repair malformed URLs by adding missing protocols. The package offers both string and object-based return modes, validation of TLD names, and extensibility through custom TLD source parsers and lists.
The library maintains a cached copy of the Public Suffix list and provides a command-line tool to refresh it. It has no external runtime dependencies, making it simple to integrate into URL-parsing pipelines, domain validation workflows, and security tools that need reliable domain decomposition.
Use it for
- Validate and extract domain components from user-submitted URLs in web applications.
- Parse and categorize domains in log analysis or security monitoring tools.
- Build domain-based access control or cookie-scoping logic in web frameworks.
- Identify first-level domains for analytics or tracking across subdomains.
- Validate TLD names against the Public Suffix list in data pipelines.
- Implement custom domain parsing rules by subclassing the base parser for specialized use cases.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
tld is a stable, actively maintained utility with zero dependencies, broad Python version support, and no known vulnerabilities. Its copyleft license requires review if you distribute proprietary code, but the license terms are well-established. Install it for any project needing reliable URL-to-domain decomposition.
Install
tld on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent commits and stable production status across modern Python versions (3.9–3.15).
Requires Python 3.7 or greater; TLD names list should be updated via `update-tld-names` if domain recognition fails.
License in practice
Copyleft license (MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later) requires derivative works to be distributed under compatible terms; review your project's license compatibility before use.
Quickstart
pip install tld
from tld import get_tld
get_tld("http://www.google.co.uk")
# 'co.uk'
get_tld("http://www.google.idontexist", fail_silently=True)
# None
Verify before relying
- Frequency and process for updating the Public Suffix list bundled with releases.
- Performance characteristics when parsing large batches of URLs.
- Whether custom parser implementations are commonly used in production.
Package facts
| License | MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later copyleft |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 161 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 15,866,317 / month, #1,171 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/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.9Topic :: Internet |
Evidence: tld-0.13.2-py2.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 › “extract tld from url”
- tldExtracts the top-level domain (TLD) and first-level domain (FLD) from…
- tldextractAccurately extracts subdomain, domain, and public suffix from URLs…
- tldparseParses domain names into their constituent parts (subdomain, domain,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Internet packages
Botocore provides low-level, data-driven access to Amazon Web Services APIs, serving as the foundation for the AWS CLI and boto3 libraries.
Install it if you need programmatic access to AWS services.
Provides an async client for AWS services using botocore and aiohttp, allowing you to call AWS APIs asynchronously within asyncio-based applications.
Install it if you need to call AWS services from async Python code; it is the standard way to do so.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides common Protocol Buffer message definitions used across Google Cloud APIs, enabling Python clients to interact with Google services.
See also tldextract · tlds · publicsuffix2 · urlextract · pyfaup-rs · tldparse · publicsuffixlist · python-whois · dnstwist · whois