Skip to content

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

License

Notifications You must be signed in to change notification settings

tompec/top-level-domains

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 test to ensure all tests are passing
  5. Run npm run sort to ensure the TLD list is properly sorted
  6. Submit a pull request

License

MIT

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published