Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

tldts

Latest version: v7.6.1

Overview

Last scanned
26 Nov 2026
Published
26 Nov 2026
npm package Publisher: remusao
782 Stars
35 Forks
23 Versions
632.0M Downloads
TypeScript Repo language

Scan summary

tldts was last scanned on 26 Nov 2026 at version 7.6.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 23 versions; the latest 2 were published within 2 days (25 and 26 Nov 2026).
  • Findings: No rules fired in version 7.6.1.
  • Downloads: 632,009,072 downloads.

Versions

23 versions published
Versions and the rules that fired in each
VersionPublishedStatus
7.6.1 LATEST 26 Nov 2026 No rules fired
7.5.6 25 Nov 2026 No rules fired
7.5.5 19 Nov 2026 No rules fired
7.5.4 15 Nov 2026 Not shown
7.5.3 14 Nov 2026 Not shown

No rules fired in 7.6.1

Findings

Findings for v7.6.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 7.6.1; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

tldts - Blazing Fast URL Parsing

tldts is a JavaScript library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs.

Features:

  1. Tuned for performance (order of 0.1 to 1 μs per input)
  2. Handles both URLs and hostnames
  3. Unicode and punycode hostnames (matched as written, no IDNA mapping)
  4. Support parsing email addresses
  5. Detect IPv4 and IPv6 addresses
  6. Continuously updated version of the public suffix list
  7. TypeScript, ships with umd, esm, cjs bundles and type definitions
  8. Small bundles and small memory footprint
  9. Battle tested: full test coverage and production use

Install

npm install --save tldts

Usage

Using the command-line interface:

$ npx tldts 'http://www.writethedocs.org/conf/eu/2017/'
{
  "domain": "writethedocs.org",
  "domainWithoutSuffix": "writethedocs",
  "hostname": "www.writethedocs.org",
  "isIcann": true,
  "isIp": false,
  "isPrivate": false,
  "publicSuffix": "org",
  "subdomain": "www"
}

Programmatically:

const { parse } = require('tldts');

// Retrieving hostname related informations of a given URL
parse('http://www.writethedocs.org/conf/eu/2017/');
// { domain: 'writethedocs.org',
//   domainWithoutSuffix: 'writethedocs',
//   hostname: 'www.writethedocs.org',
//   isIcann: true,
//   isIp: false,
//   isPrivate: false,
//   publicSuffix: 'org',
//   subdomain: 'www' }

Modern ES6 modules import is also supported:

import { parse } from 'tldts';

Alternatively, you can try it directly in your browser here: https://npm.runkit.com/tldts

API

  • tldts.parse(url | hostname, options)
  • tldts.getHostname(url | hostname, options)
  • tldts.getDomain(url | hostname, options)
  • tldts.getFullDomain(url | hostname, options)
  • tldts.getPublicSuffix(url | hostname, options)
  • tldts.getSubdomain(url, | hostname, options)
  • tldts.getDomainWithoutSuffix(url | hostname, options)

The behavior of tldts can be customized using an options argument for all the functions exposed as part of the public API. This is useful to both change the behavior of the library as well as fine-tune the performance depending on your inputs.

{
  // Use suffixes from ICANN section (default: true)
  allowIcannDomains: boolean;
  // Use suffixes from Private section (default: false)
  allowPrivateDomains: boolean;
  // Extract and validate hostname (default: true)
  // When set to `false`, inputs will be considered valid hostnames.
  extractHostname: boolean;
  // Validate hostnames after parsing (default: true)
  // If a hostname is not valid, not further processing is performed. When set
  // to `false`, inputs to the library will be considered valid and parsing will
  // proceed regardless.
  validateHostname: boolean;
  // Perform IP address detection (default: true).
  detectIp: boolean;
  // Detect IANA special-use domains (RFC 6761 et al.) and expose the result as
  // `isSpecialUse` (default: false). Off by default so the common path does no
  // extra work; the field stays `null` unless this is enabled.
  detectSpecialUse: boolean;
  // Assume that both URLs and hostnames can be given as input (default: true)
  // If set to `false` we assume only URLs will be given as input, which
  // speed-ups processing.
  mixedInputs: boolean;
  // Hostnames to treat as registrable domains, e.g. ['localhost'] (default: null)
  validHosts: string[] | null;
  // Extra public suffix rules, in PSL syntax, per section (default: null)
  // See "Adding public suffixes" below.
  extraSuffixes: { icann?: readonly string[]; private?: readonly string[] } | null;
}

The parse method returns handy properties about a URL or a hostname.

const tldts = require('tldts');

tldts.parse('https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv');
// { domain: 'amazonaws.com',
//   domainWithoutSuffix: 'amazonaws',
//   hostname: 'spark-public.s3.amazonaws.com',
//   isIcann: true,
//   isIp: false,
//   isPrivate: false,
//   publicSuffix: 'com',
//   subdomain: 'spark-public.s3' }

tldts.parse(
  'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv',
  { allowPrivateDomains: true },
);
// { domain: 'spark-public.s3.amazonaws.com',
//   domainWithoutSuffix: 'spark-public',
//   hostname: 'spark-public.s3.amazonaws.com',
//   isIcann: false,
//   isIp: false,
//   isPrivate: true,
//   publicSuffix: 's3.amazonaws.com',
//   subdomain: '' }

tldts.parse('gopher://domain.unknown/');
// { domain: 'domain.unknown',
//   domainWithoutSuffix: 'domain',
//   hostname: 'domain.unknown',
//   isIcann: false,
//   isIp: false,
//   isPrivate: false,
//   publicSuffix: 'unknown',
//   subdomain: '' }

tldts.parse('https://192.168.0.0'); // IPv4
// { domain: null,
//   domainWithoutSuffix: null,
//   hostname: '192.168.0.0',
//   isIcann: null,
//   isIp: true,
//   isPrivate: null,
//   publicSuffix: null,
//   subdomain: null }

tldts.parse('https://[::1]'); // IPv6
// { domain: null,
//   domainWithoutSuffix: null,
//   hostname: '::1',
//   isIcann: null,
//   isIp: true,
//   isPrivate: null,
//   publicSuffix: null,
//   subdomain: null }

tldts.parse('tldts@emailprovider.co.uk'); // email
// { domain: 'emailprovider.co.uk',
//   domainWithoutSuffix: 'emailprovider',
//   hostname: 'emailprovider.co.uk',
//   isIcann: true,
//   isIp: false,
//   isPrivate: false,
//   publicSuffix: 'co.uk',
//   subdomain: '' }
Property Name Type Description
hostname str hostname of the input extracted automatically
domain str Domain (tld + sld)
domainWithoutSuffix str Domain without public suffix
subdomain str Sub domain (what comes after domain)
publicSuffix str Public Suffix (tld) of hostname
isIcann bool Does TLD come from ICANN part of the list
isPrivate bool Does TLD come from Private part of the list
isIP bool Is hostname an IP address?
isSpecialUse bool Is hostname an IANA special-use domain?

Special-use domains (RFC 6761 / IANA)

Set { detectSpecialUse: true } to flag reserved special-use names such as localhost, *.test, *.local, *.onion, and home.arpa via the isSpecialUse result field. isIcann/isPrivate don't identify these: most aren't in the Public Suffix List, and the few that are (e.g. onion, home.arpa) appear there as ordinary ICANN suffixes. The field is null unless the option is enabled, so the default path does no extra work:

parse('http://printer.local/', { detectSpecialUse: true });
// { ...
//   isSpecialUse: true,
//   publicSuffix: 'local',
//   subdomain: '' }

The list tracks the IANA Special-Use Domain Names registry.

Single purpose methods

These methods are shorthands if you want to retrieve only a single value (and will perform better than parse because less work will be needed).

getHostname(url | hostname, options?)

Returns the hostname from a given string.

const { getHostname } = require('tldts');

getHostname('google.com'); // returns `google.com`
getHostname('fr.google.com'); // returns `fr.google.com`
getHostname('fr.google.google'); // returns `fr.google.google`
getHostname('foo.google.co.uk'); // returns `foo.google.co.uk`
getHostname('t.co'); // returns `t.co`
getHostname('fr.t.co'); // returns `fr.t.co`
getHostname(
  'https://user:password@example.co.uk:8080/some/path?and&query#hash',
); // returns `example.co.uk`
getDomain(url | hostname, options?)

Returns the fully qualified domain from a given string.

const { getDomain } = require('tldts');

getDomain('google.com'); // returns `google.com`
getDomain('fr.google.com'); // returns `google.com`
getDomain('fr.google.google'); // returns `google.google`
getDomain('foo.google.co.uk'); // returns `google.co.uk`
getDomain('t.co'); // returns `t.co`
getDomain('fr.t.co'); // returns `t.co`
getDomain('https://user:password@example.co.uk:8080/some/path?and&query#hash'); // returns `example.co.uk`
getFullDomain(url | hostname, options?)

Returns the full domain — the subdomain together with the registrable domain (as returned by getDomain(...)), i.e. the whole hostname including any subdomain — or null when the input has no registrable domain (IP address, single label, bare public suffix, …). The result is the normalized hostname (lower-cased, trailing dot stripped); it is not a DNS-absolute name (no trailing root dot) and no IDNA/punycode conversion is performed.

const { getFullDomain } = require('tldts');

getFullDomain('google.com'); // returns `google.com`
getFullDomain('fr.google.com'); // returns `fr.google.com`
getFullDomain('foo.google.co.uk'); // returns `foo.google.co.uk`
getFullDomain('t.co'); // returns `t.co`
getFullDomain('fr.t.co'); // returns `fr.t.co`
getFullDomain('1.2.3.4'); // returns null (no registrable domain)
getFullDomain('localhost'); // returns null
getDomainWithoutSuffix(url | hostname, options?)

Returns the domain (as returned by getDomain(...)) without the public suffix part.

const { getDomainWithoutSuffix } = require('tldts');

getDomainWithoutSuffix('google.com'); // returns `google`
getDomainWithoutSuffix('fr.google.com'); // returns `google`
getDomainWithoutSuffix('fr.google.google'); // returns `google`
getDomainWithoutSuffix('foo.google.co.uk'); // returns `google`
getDomainWithoutSuffix('t.co'); // returns `t`
getDomainWithoutSuffix('fr.t.co'); // returns `t`
getDomainWithoutSuffix(
  'https://user:password@example.co.uk:8080/some/path?and&query#hash',
); // returns `example`
getSubdomain(url | hostname, options?)

Returns the complete subdomain for a given string.

const { getSubdomain } = require('tldts');

getSubdomain('google.com'); // returns ``
getSubdomain('fr.google.com'); // returns `fr`
getSubdomain('google.co.uk'); // returns ``
getSubdomain('foo.google.co.uk'); // returns `foo`
getSubdomain('moar.foo.google.co.uk'); // returns `moar.foo`
getSubdomain('t.co'); // returns ``
getSubdomain('fr.t.co'); // returns `fr`
getSubdomain(
  'https://user:password@secure.example.co.uk:443/some/path?and&query#hash',
); // returns `secure`
getPublicSuffix(url | hostname, options?)

Returns the public suffix for a given string.

const { getPublicSuffix } = require('tldts');

getPublicSuffix('google.com'); // returns `com`
getPublicSuffix('fr.google.com'); // returns `com`
getPublicSuffix('google.co.uk'); // returns `co.uk`
getPublicSuffix('s3.amazonaws.com'); // returns `com`
getPublicSuffix('s3.amazonaws.com', { allowPrivateDomains: true }); // returns `s3.amazonaws.com`
getPublicSuffix('tld.is.unknown'); // returns `unknown`

Troubleshooting

Retrieving subdomain of localhost and custom hostnames

tldts methods getDomain and getSubdomain are designed to work only with known and valid TLDs. This way, you can trust what a domain is.

localhost is a valid hostname but not a TLD. You can pass additional options to each method exposed by tldts:

const tldts = require('tldts');

tldts.getDomain('localhost'); // returns null
tldts.getSubdomain('vhost.localhost'); // returns null

tldts.getDomain('localhost', { validHosts: ['localhost'] }); // returns 'localhost'
tldts.getSubdomain('vhost.localhost', { validHosts: ['localhost'] }); // returns 'vhost'

Adding public suffixes

The Public Suffix List only accepts entries from domain owners. To use suffixes it does not list, pass extraSuffixes in PSL syntax (foo.com, *.foo.com, !a.foo.com), per section:

const { getDomain, parse } = require('tldts');

getDomain('foo.us.com'); // 'us.com' (us.com is a private PSL entry)
getDomain('foo.us.com', { extraSuffixes: { icann: ['us.com'] } }); // 'foo.us.com'

parse('a.b.cdn.example', {
  allowPrivateDomains: true,
  extraSuffixes: { private: ['*.cdn.example', '!www.cdn.example'] },
}); // publicSuffix: 'b.cdn.example', domain: 'a.b.cdn.example', isPrivate: true

Updating the TLDs List

tldts made the opinionated choice of shipping with a list of suffixes directly in its bundle. There is currently no mechanism to update the lists yourself, but we make sure that the version shipped is always up-to-date.

If you keep tldts updated, the lists should be up-to-date as well!

Performance

tldts is the fastest JavaScript library available for parsing hostnames. It is able to parse millions of inputs per second (typically 2-3M depending on your hardware and inputs). It also offers granular options to fine-tune the behavior and performance of the library depending on the kind of inputs you are dealing with (e.g.: if you know you only manipulate valid hostnames you can disable the hostname extraction step with { extractHostname: false }).

Please see this detailed comparison with other available libraries.

Contributors

tldts is based upon the excellent tld.js library and would not exist without the many contributors who worked on the project:

This project would not be possible without the amazing Mozilla's public suffix list. Thank you for your hard work!

License

MIT License.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm tldts

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Critical Apache HTTP Server Flaw Exposes Web Servers to RCE (1)
CVE

CVE-2026-119618: Critical Apache HTTP Server Flaw Exposes Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229