In this documentation, you will find everything you need to know about the TLDExtract library. TLDExtract is a Swift library that allows you to easily extract the top-level domain (TLD), domain, and subdomain from a given URL.


To add TLDExtract to your project, you can simply use CocoaPods. Add the following line to your Podfile:

  • Open your project folder and locate the Podfile.
  • Add the line pod 'TLDExtract' to your Podfile.
  • Save the Podfile and run pod install command.
  • Open the newly created .xcworkspace file.
  • You can now import TLDExtract and start using it in your project.


TLDExtract provides a simple and straightforward API to extract the desired information from a URL:

// Import the TLDExtract library
import TLDExtract

// Create an instance of TLDExtract
let tldExtract = TLDExtract()

// Extract the TLD, domain, and subdomain from a URL
let url = ""
let result = tldExtract.extract(url)

print(result.tld)       // Output: com
print(result.domain)    // Output: example
print(result.subdomain) // Output: www


1. Extract TLD, Domain, and Subdomain

TLDExtract allows you to easily extract the top-level domain (TLD), domain, and subdomain from a given URL with just a few lines of code.

2. Customizable Options

With TLDExtract, you can customize various options to meet your specific requirements. You can disable the extraction of subdomains or enable the extraction of private domains.

3. Lightweight and Efficient

TLDExtract is built with performance in mind, ensuring minimal impact on your application. The library is lightweight and doesn’t introduce unnecessary overhead.


With TLDExtract, you can easily extract the necessary domain information from any URL. Its simplicity, flexibility, and efficiency make it an ideal choice for working with URLs in your Swift projects.