skillfed

publicsuffixlist

publicsuffixlist implement

publicsuffixlist v1.0.2.20260726 1.8M downloads/30d#3,525 on PyPI80
Copyleft license MPL-2.0 Active released

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 publicsuffixlist

uv

uv add publicsuffixlist

poetry

poetry add publicsuffixlist

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Operating System :: OS IndependentTopic :: Internet :: Name Service (DNS)Topic :: Text Processing :: Filters

Tags

public suffix list parserdomain name parsingextract registrable domainIDN domain handlingTLD extractionpunycode domain supportdomain suffix lookup
domain-parsinginternationalizationsecurity-boundary

More Filters packages