Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


The TLD proliferation makes it difficult to check whether domain names are valid. This project uses the rules of, a list of known public domain suffixes (TLD) to validate and split domains into three the parts (TLD, domain, subdomain). The validation rules are loaded directly from

A domain name has 3 major parts:

Example TLD Domain Subdomain com google blog org wikipedia www ru yandex mail amazon www


The package is available on nuget

PM> install-package Nager.PublicSuffix

Online test tool

You can try the logic right here publicsuffix test tool


  • High performance
  • FileTldRuleProvider or WebTldRuleProvider
  • CacheProvider
  • Async support


Loading data from web (

Without any config the WebTldRuleProvider have a default cache live time of 1 day then you must refresh the cache with execute BuildAsync;

var domainParser = new DomainParser(new WebTldRuleProvider());

var domainName = domainParser.Get("");
//domainName.Domain = "test";
//domainName.Hostname = "";
//domainName.RegistrableDomain = "";
//domainName.SubDomain = "sub";
//domainName.TLD = "";

Loading data from web change cache config

//cache data for 10 hours
var cacheProvider = new FileCacheProvider(cacheTimeToLive: new TimeSpan(10, 0, 0));
var webTldRuleProvider = new WebTldRuleProvider(cacheProvider: cacheProvider);

var domainParser = new DomainParser(webTldRuleProvider);
for (var i = 0; i < 100; i++)
    var isValid = webTldRuleProvider.CacheProvider.IsCacheValid();
    if (!isValid)
        webTldRuleProvider.BuildAsync().GetAwaiter().GetResult(); //Reload data
    var domainInfo = domainParser.Get($"sub{i}");

Loading data from file

var domainParser = new DomainParser(new FileTldRuleProvider("effective_tld_names.dat"));

var domainName = domainParser.Get("");
//domainName.Domain = "test";
//domainName.Hostname = "";
//domainName.RegistrableDomain = "";
//domainName.SubDomain = "sub";
//domainName.TLD = "";
You can’t perform that action at this time.