--- id: tldextract version: "5.3.2" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # 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. License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install tldextract uv add tldextract poetry add tldextract ## Description # tldextract [![PyPI version](https://badge.fury.io/py/tldextract.svg)](https://badge.fury.io/py/tldextract) [![Build Status](https://github.com/john-kurkowski/tldextract/actions/workflows/ci.yml/badge.svg)](https://github.com/john-kurkowski/tldextract/actions/workflows/ci.yml) `tldextract` accurately separates a URL's subdomain, domain, and public suffix, using [the Public Suffix List (PSL)](https://publicsuffix.org). **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 ```python >>> 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 ```zsh pip install tldextract ``` ## How-to Guides ###... ## AI interpretation — verify before relying 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. 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. [View on SkillFed](https://skillfed.io/packages/tldextract) · [View on PyPI](https://pypi.org/project/tldextract/)