Skip to content

Repository files navigation

TLD List

This repository contains a list of all existing Top-Level Domains (TLDs) that can be registered.

This includes:

Installation

npm install top-level-domains
# or
yarn add top-level-domains

Usage

// ESM
import { tlds, isTld, getPunycode, searchTlds, getAllTlds } from 'top-level-domains';

// CommonJS
const { tlds, isTld, getPunycode, searchTlds, getAllTlds } = require('top-level-domains');

// Check if a string is a valid TLD
console.log(isTld('com')); // true
console.log(isTld('notarealtld')); // false

// Get the punycode representation of a TLD
console.log(getPunycode('台灣')); // 'xn--kpry57d'

// Search for TLDs containing a string
const results = searchTlds('com');
console.log(results); // Returns all TLDs containing 'com'

// Get all TLDs as an array of strings
const allTlds = getAllTlds();
console.log(allTlds); // Returns all TLDs as an array of strings

Structure

Each TLD entry in the data.json file is structured as follows:

{
  "tld": "example",
  "punycode": "example"
}

For internationalized domain names (IDNs), the punycode representation is different:

{
  "tld": "台灣",
  "punycode": "xn--kpry57d"
}

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bugfix
  3. Make your changes
  4. Run npm run process to normalise the TLD list and run the tests
  5. Submit a pull request

License

MIT

About

A comprehensive list of all existing Top-Level Domains (TLDs).

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages