tldts
tldts: Fast Domain, Subdomain, and TLD Parsing for JS
Repository Health
Technical Analysis
tldts is a JavaScript/TypeScript library that extracts hostnames, domains, public suffixes, top-level domains, and subdomains from URLs or raw hostnames. It’s built specifically for performance — the project benchmarks itself against competing libraries like psl, tldjs, parse-domain, and tld-extract, and consistently leads on operations-per-second for getDomain-style parsing on real-world URL corpora.
Unlike naive suffix-splitting approaches, tldts uses a continuously updated copy of the public suffix list compiled into an efficient suffix trie, giving spec-correct results for tricky cases like multi-part suffixes (co.uk), private domains, IDNA/Unicode hostnames, IP address detection, and email address parsing. The monorepo splits functionality across tldts-core (shared parsing logic), tldts-icann/tldts (different public-suffix-list scopes), and tldts-experimental, so consumers can pick a bundle sized to their needs.
What You Get
parse()function returning domain, domainWithoutSuffix, hostname, subdomain, publicSuffix, isIcann, isPrivate, and isIp fields for any URL or hostname- A CLI (
npx tldts <url>) for one-off or batched (stdin) domain parsing without writing any code - IPv4/IPv6 address detection built into the same parsing path as domain extraction
- Full Unicode/IDNA support for internationalized domain names
- Email address parsing support, extracting the domain portion of an email address the same way as a URL
Common Use Cases
- Grouping or deduplicating analytics/log data by registrable domain instead of full hostname (e.g.
mail.google.comandwww.google.comboth resolving togoogle.com) - Validating and normalizing user-submitted URLs or email addresses in a signup or content-moderation pipeline
- Cookie and security tooling that needs correct public-suffix-aware domain boundaries (e.g. determining if a cookie can be set across
co.uksubdomains) - Ad-tech and privacy tools (its author’s browser extension work) that need fast, spec-correct domain classification at scale
Under The Hood
Architecture The monorepo splits concerns cleanly: tldts-core/src/factory.ts builds a configurable parser factory that other packages instantiate with a specific public-suffix dataset, extract-hostname.ts/is-ip.ts/is-valid.ts handle input normalization and validation, and the top-level tldts package’s src/suffix-trie.ts (207 lines) compiles the public suffix list into a trie structure for O(suffix-length) lookups rather than linear list scanning. tldts-icann and tldts-experimental reuse the same tldts-core engine with different suffix datasets (ICANN-only vs. experimental/private suffixes). Tech Stack Pure TypeScript across all six packages, built with Rollup to ESM/CJS/UMD bundles per package, with a bin/ CLI entry point in the tldts package wrapping the same parse() function used programmatically; the project maintains its own benchmark harness (comparison/bench2) comparing throughput against competing libraries on every release. Code Quality tldts-tests is a dedicated package solely for cross-package test fixtures, and packages/tldts/test/ runs dedicated suites (tld.test.ts, publicsuffix.test.ts, special-use.test.ts) covering ICANN rules, private suffixes, and RFC 6761 special-use names (localhost, .test, .invalid, .onion, etc.); the repo’s active commit cadence and consistent dependency updates (via dependabot) reflect ongoing maintenance discipline. API Design The single parse() function with a flat result object (domain, subdomain, publicSuffix, isIcann, isPrivate, isIp) is easy to start with, and the bundled CLI mirrors the same shape for shell use without writing code; choosing between the tldts, tldts-icann, and tldts-experimental variants does require reading the docs to understand suffix-list scope trade-offs, but the default tldts package covers the common case out of the box.
Used by 20 apps in this directory
AFFiNE
Productivity · Project Management · Note Taking
Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.
Bramble
Password Manager · Security · Authentication
Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Firecrawl
AI Development · Developer Tools
Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.
Ghost
CMS · Blogging
Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Onlook
Design Tools · AI Design Tools
An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.
open-seo
Marketing · Developer Tools
Pay-as-you-go open source SEO platform with MCP integration — keyword research, rank tracking, backlinks, site audits, and AI brand visibility in one self-hosted tool.