A Full Swift Lightweight Framework that uses the Public Suffix list to Parse URLs

Domain Parser

Carthage Compatible

A full-swift simple library which allows to parse host to parse hostnames, and public suffix, using the Public Suffix List

This Library allows to know which is the domain name for a given URL.

What is Public Suffix List ?

PSL list all the known public suffix (like: com,,, ...). Without this information we are not able to determine which part of a URL is the domain, Since a suffix can have more than one Label. The PSL includes ICANN (official top level domains) but also privates one (like


URL Domain



import DomainParser
let domainParse = try DomainParser()

You should use the same instance when you parse multiple URLs.

let domain = domainParser.parse("").domain
print(domain) //
let suffix = domainParser.parse("").suffix
print(suffix) // com
let suffix = domainParser.parse("").suffix
print(suffix) //

Update the Public Suffist List

In the script folder, run:

swift UpdatePSL.swift 


  • Swift Tools 5.3.0
View More Packages from this Author


  • None
Last updated: Mon Feb 06 2023 07:29:45 GMT-0500 (GMT-05:00)