Guides

How to Extract Domains & Hostnames from URLs and Text Online

To extract clean root domains or Fully Qualified Domain Names (FQDNs) from a list of URLs, email addresses, or log files without breaking on multi-part country TLDs like .co.uk or .com.au, parse the hostnames and strip protocols, ports, paths, and `www.` prefixes directly in your browser using the EasyExtract Domain Extractor. Everything runs 100% client-side in local RAM with zero server uploads, outputting a deduplicated domain list ready for SEO backlink audits, firewall allowlists, or DNS lookups.

SEO specialists auditing 50,000 backlink URLs, cybersecurity engineers compiling DNS sinkhole blocklists from proxy logs, and B2B outreach teams deduplicating prospect websites all face the same problem: converting messy URLs like `https://app.staging.example.co.uk:8443/login?ref=123` into clean, normalized domain names (`example.co.uk` or `app.staging.example.co.uk`).

This guide explains why simple Excel `MID`/`FIND` formulas and naive `.split(‘.’)` scripts fail on real-world domains and shows you how to extract and normalize domains accurately.

Root Domain (eTLD+1) vs. Subdomain (FQDN): Why `.co.uk` Breaks Naive Formulas

Under RFC 1035 and Mozilla’s Public Suffix List (PSL), a URL’s hostname consists of multiple dot-separated labels read from right to left:

  • Top-Level Domain (TLD / Public Suffix): While generic TLDs like `.com`, `.org`, and `.io` occupy a single label, dozens of major country-code second-level domains (**ccSLDs**) occupy **two labels**—such as `.co.uk` (United Kingdom), `.com.au` (Australia), `.co.jp` (Japan), `.com.br` (Brazil), and `.co.in` (India).
  • Registrable Root Domain (`eTLD+1` / Apex Domain): The public suffix plus one preceding label (for example, `bbc.co.uk` or `stripe.com`). If a naive script simply grabs the “last two dot-separated words” (`hostname.split(‘.’).slice(-2).join(‘.’)`), it turns `shop.tesco.co.uk` into **`co.uk`**—destroying your dataset!
  • Fully Qualified Domain Name (FQDN / Hostname): Includes all subdomains (such as `api.v2.stripe.com`), excluding the `https://` scheme, `:port`, and `/path`.

Method 1: Extract & Deduplicate Domains Online in Your Browser (Zero Uploads)

To strip thousands of URLs, email addresses, or raw text logs down to unique domains in under a second:

  1. Open the free Domain Extractor on EasyExtract.
  2. Paste your list of URLs, HTML snippets, or raw log text into the input box.
  3. Choose Subdomain & `www.` Handling: Toggle whether to strip `www.` prefixes, whether to collapse subdomains down to the registrable root domain (`eTLD+1`), and whether to deduplicate and sort alphabetically.
  4. Click Copy Domains or download the clean list as a `.txt` or `.csv` file.
Input String Full Hostname (FQDN) Root Domain (`eTLD+1`) Naive Excel Formula Output (Broken)
https://www.stripe.com/docs/api?v=2 www.stripe.com stripe.com www.stripe.com
https://portal.nhs.uk:8080/login portal.nhs.uk nhs.uk portal.nhs.uk:8080 (keeps port)
https://store.Waitrose.co.uk/offers store.waitrose.co.uk waitrose.co.uk co.uk (truncates brand!)

Method 2: Extract Domains in Microsoft Excel & Google Sheets

If you need a quick formula inside a spreadsheet to strip `http://`, `https://`, `www.`, and everything after the first `/` slash:

Google Sheets `REGEXEXTRACT` Formula (Best for Sheets)

=LOWER(REGEXEXTRACT(A2, "^(?:https?://)?(?:www\.)?([^/:?#]+)"))

Microsoft Excel Formula

=LOWER(SUBSTITUTE(MID(A2, FIND("//", A2)+2, FIND("/", A2&"/", FIND("//", A2)+2) - FIND("//", A2) - 2), "www.", ""))

Pair the Domain Extractor with our companion network and SEO utilities in the Text & Pattern Extraction Hub:

Frequently Asked Questions

Can the Domain Extractor pull domains out of email addresses too?

Yes. When your text contains email addresses (`support@company.io`) alongside web URLs (`https://blog.company.io/post`), the extractor isolates the domain portion after `@` as well as URL hostnames.

Does it remove port numbers like `:8080` or `:443`?

Yes. Port numbers, URL paths (`/path`), query strings (`?id=1`), and hash fragments (`#top`) are automatically stripped so only valid DNS hostnames remain.

Are my backlink lists or firewall logs uploaded to a server?

Never. All hostname parsing and deduplication happen 100% locally in your browser’s RAM.

Shah Abrar Ahmad - Founder & Lead Engineer
Lead Architect & Founder

Software architect and technical web engineer specializing in browser-based zero-knowledge file parsing, technical SEO, and data extraction security. Built EasyExtract to give users 100% private in-browser tools with zero cloud uploads.

Keep reading