https://github.com/katmore/tld-enum
Lists of every ICANN TLD in multiple formats
https://github.com/katmore/tld-enum
csv csv-files enumeration iana iana-database icann javascript json node php php7 tld top-level-domains
Last synced: 2 months ago
JSON representation
Lists of every ICANN TLD in multiple formats
- Host: GitHub
- URL: https://github.com/katmore/tld-enum
- Owner: katmore
- License: mit
- Fork: true (incognico/list-of-top-level-domains)
- Created: 2017-12-04T21:31:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T03:34:32.000Z (almost 8 years ago)
- Last Synced: 2025-10-17T05:43:07.938Z (5 months ago)
- Topics: csv, csv-files, enumeration, iana, iana-database, icann, javascript, json, node, php, php7, tld, top-level-domains
- Language: JavaScript
- Homepage:
- Size: 388 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TLD Enumerations
Lists of every [IANA TLD](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) in various formats. The lists may be continuously updated using the included [update utility](#updating-the-tld-format-files) that pulls the latest data from IANA.
* [CSV Format](./tlds.csv)
* [All Format Files](#tld-list-formats)
* [Updating the Format Files](#updating-the-tld-format-files)
* [Node Usage](#node-usage)
* [PHP Usage](#php-usage)
## Usage
Because the lists are provided in universial CSV and JSON formats, they can be easily utilitized in most programming environments.
Additionally, for convenience, some native programming language formats have also been provided.
* [Node Usage](#node-usage)
* [More Node Examples](#more-node-examples)
* [PHP Usage](#php-usage)
* [More PHP Examples](#more-php-examples)
### Node Usage
* use npm to add the `tld-enum` package to your project
```sh
$ npm install tld-enum --save
```
* add the module to your source
```js
const tldEnum = require('tld-enum');
```
* access the list by using the `tldEnum.tldList` array
```js
const tldEnum = require('tld-enum');
console.log(tldEnum.list); //an array with every IANA TLD
```
The following example...
```js
const tldEnum = require('tld-enum');
console.log("There are " + tldEnum.list.length + " IANA TLDs");
let tldCheck;
tldCheck = "com";
console.log("Is '" + tldCheck + "' a real TLD?");
if (tldEnum.list.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
} else {
console.log(" no");
}
tldCheck = "somethingWeird";
console.log("Is '" + tldCheck + "' a real TLD?");
if (tldEnum.list.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
} else {
console.log(" no");
}
```
Should produce the following output...
```txt
There are 1577 IANA TLDs
Is 'com' a real TLD?
yes
Is 'somethingWeird' a real TLD?
no
```
#### More Node Examples
* [js-demo.js](/examples/js-demo.js) Demo using the simple array of every TLD in JavaScript.
* [js-desc-demo.js](/examples/js-desc-demo.js) Demo using the TLD description hashmap in JavaScript.
* [js-type-demo.js](/examples/js-type-demo.js) Demo using the TLD type hashmap in JavaScript.
* [js-info-demo.js](/examples/js-info-demo.js) Demo using the array of TLD info hashmaps in JavaScript.
### PHP Usage
* use composer to add the `katmore/tld-enum` package to your project
```sh
$ composer require katmore/tld-enum
```
* access the list by using the `\TldEnum\TldList::TLD_LIST` class constant array
```php