publicsuffixlist
publicsuffixlist implement
What it is and what it does
publicsuffixlist is a pure-Python parser for the Public Suffix List, a Mozilla-maintained registry of domain suffixes (like .com, .co.uk, and many others). It determines what portion of a domain name is the public suffix and what portion is privately registrable—useful for cookie handling, domain validation, and security contexts where you need to know the "effective" domain of a given hostname.
The package ships with a built-in, daily-updated PSL file and supports both Unicode and Punycode-encoded internationalized domain names (IDNs). It has no external dependencies, installs as a wheel, and includes an updater script if you need to use a custom PSL file. The API is straightforward: call `publicsuffix()` to get the longest public suffix, `privatesuffix()` to get the shortest registrable domain, and helper methods like `is_private()` and `subdomain()` for common tasks.
Use it for:
- Determine the registrable domain from a URL to enforce same-site cookie policies or security boundaries.
- Extract the effective domain from a list of hostnames for analytics or logging aggregation.
- Validate whether a given domain is a known public suffix (e.g., to reject registrations at the TLD level).
- Handle internationalized domain names in Unicode or Punycode form without manual encoding logic.
- Parse domain hierarchies to identify subdomains and their relationship to the registrable domain.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses the Public Suffix List to extract the public and private (registrable) portions of domain names, with support for internationalized domain names and Punycode.
Yes. The package is actively maintained, has zero known vulnerabilities, installs with no friction, and solves a well-defined problem that many applications need. The copyleft license (MPL 2.0) is permissible for most use cases as long as modifications are disclosed. Install it if you need reliable public suffix parsing; the daily-updated built-in list and pure-Python implementation make it a practical choice.
Install
publicsuffixlist on PyPI
pip
pip install publicsuffixlistuv
uv add publicsuffixlistpoetry
poetry add publicsuffixlistInstalling publicsuffixlist
Before you install
Low friction: pure Python with no runtime dependencies, distributed as a wheel. Actively maintained with a release 19 days ago; last commit on 2026-07-26. Dropped Python 2.7 and 3.4 support at version 1.0.0 in June 2024.
License in practice
Licensed under Mozilla Public License 2.0 (copyleft). Requires derivative works and modifications to be disclosed under the same license; permissible for proprietary use if license terms are respected.
Quickstart
from publicsuffixlist import PublicSuffixList
psl = PublicSuffixList()
print(psl.publicsuffix("www.example.com")) # "com"
print(psl.privatesuffix("www.example.com")) # "example.com"
Requires Python 3.5 or later; Python 2.7 and 3.4 are no longer supported.
Verify before relying
- Whether the built-in PSL file is updated daily as claimed, or how frequently updates occur in practice.
- Performance characteristics when parsing very large domain lists or with deeply nested subdomains.
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 19 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,813,995/month — #3,525 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: publicsuffixlist-1.0.2.20260726-py2.py3-none-any.whl
Tags
More Filters packages
Pygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
pandocfiltersProvides Python utilities for writing pandoc…
permissive · top 1,000 on PyPI
UnidecodeConverts Unicode text to ASCII-safe…
copyleft · top 1,000 on PyPI
pymdown-extensionsPymdown Extensions provides a collection of…
permissive · top 1,000 on PyPI
publicsuffix2Extracts the public suffix and registrable…
copyleft · top 5,000 on PyPI
tldextractAccurately extracts subdomain, domain, and…
permissive · top 1,000 on PyPI
idnaConverts domain names between Unicode and…
permissive · top 100 on PyPI
domain2idnaConverts domain names and URLs to Punycode/IDNA…
permissive · top 15,000 on PyPI
ioc-fangerConverts defanged indicators of compromise…
permissive · top 15,000 on PyPI
tldsProvides a set of valid top-level domains…
permissive · top 15,000 on PyPI
tldExtracts the top-level domain (TLD) and…
copyleft · top 5,000 on PyPI
tldparseParses domain names into their constituent…
permissive · top 15,000 on PyPI
python-whoisQueries WHOIS servers directly to retrieve and…
permissive · top 5,000 on PyPI
atpublicProvides @public and @private decorators to…
permissive · top 5,000 on PyPI