Premium tools, free for everyone. Most run right in your browser.

OpenMultiURL

Links and URLs

How to Extract Domains From URLs Without Losing Detail

How to Extract Domains From URLs Without Losing Detail title on a coloured card

A list containing blog.example.com and shop.example.com creates a small but important choice: do you want two hosts or one registered domain? I settle that before removing anything. Otherwise, a tidy result can hide information you still need. If you're learning how to extract domains from URLs, I'll show you how I separate those jobs, use Domain Extractor, and check awkward entries such as example.co.uk, addresses with ports, and links without a scheme.

What part of a URL should I extract?

I use hostname when I mean the full host name, such as support.example.com. I use registered domain for the registrable name, such as example.com. People often call both a domain, which explains plenty of confusing instructions. Before you start, write down which result you need.

A hostname is not the whole URL

Take https://shop.example.com:8443/products?colour=blue as a practice address. Its hostname is shop.example.com. Its host includes the port: shop.example.com:8443. The path and query are separate. I use the MDN explanation of URL parts as a useful reference because it keeps these pieces distinct.

I choose an output based on the question I need to answer.
My taskWhat I keepExample
Review separate website areasHostnameshop.example.com
Group pages by registered domainRegistrable domainexample.com
Identify a service using a portHost, including a non-default portshop.example.com:8443
Compare browser originsScheme, hostname, and porthttps://shop.example.com:8443

I don't assume that a hostname is a public domain. It can also be an IP address, and development lists may contain localhost or internal names. Those entries need their own category rather than a forced conversion into something ending in .com. Extracting a value and classifying it are separate jobs.

How do I extract domains from URLs with Domain Extractor?

I built Domain Extractor and tried the steps here with it. I test my tools on a budget Android phone and a laptop. My advice is to begin with a short sample whose expected results you can write down yourself. That checks the output you actually get instead of relying on the word domain in a tool's title.

  1. Keep a copy of your source URLs before editing anything.
    • In a spreadsheet, leave the original column untouched.
    • Include a normal address, a subdomain, and a country-code example in your sample.
  2. Open Domain Extractor and paste your sample into its URL input, with one address per line.
  3. Run the extraction and compare the result with your expected hostname or registered domain.
    • Check whether www and other subdomains remain.
    • Check whether a port is absent from hostname output.
  4. Paste the rest of your list only after the sample matches your goal.
  5. Copy the results into a separate column or document, then inspect missing entries before deduplicating.

Check the output rather than assuming a mode

I wouldn't promise a root-domain result just because an extraction succeeds. If the output keeps blog.example.com, you have a hostname. If you need example.com, that is another operation requiring suffix-aware handling. I also compare input and output rows before assuming their positions still match, because skipped entries or merged duplicates can break that relationship.

Tip from me: I keep one known example beside the result while working on my phone. It's easier to spot a missing subdomain there than to inspect a long pasted list after I've replaced the source.

Should I keep subdomains or extract the root domain?

I keep subdomains by default because I can group them later. Removing them immediately is harder to undo if the original list disappears. For a review of support, shop, and blog areas, those names carry useful meaning. For a broad count of registered domains, they may be more detail than you need.

Why the last two parts can be wrong

For news.example.co.uk, taking the last two labels gives co.uk. That's a public suffix, not the registered domain you wanted. The Public Suffix List describes suffixes such as com and co.uk. I use suffix-aware handling for this job rather than a rule that counts dots.

These examples show why I label each output column explicitly.
Input URLHostnameRegistered domain
https://www.example.com/articlewww.example.comexample.com
https://blog.example.com/blog.example.comexample.com
https://news.example.co.uk/storynews.example.co.ukexample.co.uk
https://127.0.0.1:3000/test127.0.0.1Not a registered domain

Removing only www is also different from removing every subdomain. It leaves blog.example.com untouched. I treat www removal as a specific formatting choice, not a complete root-domain method. And I don't maintain a tiny homemade list of country suffixes, because regional rules vary and a fixed list can miss cases.

How do I extract a domain from a URL in Excel?

I use a spreadsheet formula only when I can describe its limits clearly. For a simple Excel example, put https://blog.example.com/article in A2. The formula below takes the text after :// and stops at the next slash. With this particular input, the result is blog.example.com.

=TEXTBEFORE(TEXTAFTER(A2,"://")&"/","/")

Where this short formula stops being enough

I wouldn't apply that formula blindly to a mixed export. It doesn't remove credentials or ports. An address with a query directly after the hostname can leave query text in the result. It also expects the scheme separator to exist. If Excel doesn't recognise TEXTBEFORE or TEXTAFTER in your installation, use Domain Extractor rather than trying random edits to the formula.

  • I keep full URL text in the source cells, not just visible labels such as Visit website.
  • I place the formula result in a new column and inspect unusual rows before filling it through the whole list.
  • I label this result as a hostname only when the source format rules out ports, credentials, and other leftover parts.

A clickable cell needs particular care. I first establish whether its value is an actual URL or whether the address is attached to display text. A text formula needs the address itself. Extracting from the words Read more won't recover a hostname, however tidy the formula looks.

How do I extract domains in Google Sheets?

In Google Sheets, I use this limited formula for HTTP or HTTPS addresses stored as plain text in A2. It captures the authority, the part after the scheme and before a slash, question mark, or fragment marker. For https://blog.example.com/article, that happens to be the hostname.

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

I call it an authority formula deliberately. With https://example.com:8443/page, it returns example.com:8443, not just the hostname. Embedded user information would remain too. The formula also expects a lowercase HTTP or HTTPS scheme at the start. It's useful for controlled input, but I wouldn't describe it as a general URL parser.

If the result is wrong, I inspect the source rather than wrapping every failure in a blank result. Blank cells can hide a missing scheme, a display label, or a damaged address. Google also documents that ISURL can reject a top-level domain absent from its list, so I don't treat that function as the final authority on domain validity.

Tip from me: I keep a separate needs-review column for failed spreadsheet rows. A visible failure is more useful than an empty cell that quietly disappears from the final count.

Which method should I use for a bulk URL list?

I choose a method based on how mixed the inputs are and whether I'll repeat the work. A short, consistent spreadsheet column doesn't need the same setup as a recurring export containing ports, international names, and internal addresses. Speed matters less if a quick rule silently groups unrelated entries.

This is how I decide between common extraction methods.
MethodWhen I'd choose itWhat I'd check
Manual inspectionA short sample or a disputed resultEvery URL component
Domain ExtractorA pasted list without writing formulasSubdomain output and failed rows
Spreadsheet formulaA controlled text columnUnsupported input patterns
URL parser in a scriptA repeatable cleanup processParsing failures and hostname output
Public suffix handlingRegistered-domain groupingSuffix rules and non-domain hosts

For scripts, I separate parsing from grouping

In JavaScript, the expression new URL(value).hostname asks for the hostname. The host property can include a port, so it isn't interchangeable. I handle parsing failures separately and apply an explicit policy to inputs without a scheme. Registered-domain grouping then needs suffix-aware logic. A URL parser alone doesn't turn news.example.co.uk into example.co.uk.

For a puzzling individual address, I use URL Parser to inspect its parts before changing a bulk rule. That makes the problem easier to name: perhaps the output includes a port, or perhaps the supposed domain was actually text inside a query.

How do I handle ports, bare domains, and unusual hosts?

I put unusual inputs into review groups rather than forcing every line through the same shortcut. An extraction workflow should explain what it leaves out. Otherwise, a neat domain column can conceal the exact addresses that needed attention most.

  • Ports: for https://example.com:8443/, I expect example.com as the hostname. I preserve the original address if the service identity matters.
  • Missing schemes: for example.com/page, I decide explicitly whether to interpret it as a web address before adding a scheme.
  • IP addresses and localhost: I keep these separate from registered public domains instead of trying to remove their leftmost parts.
  • International names: I check whether the output uses readable Unicode or an ASCII-compatible IDN representation before comparing results.
  • User information: I don't mistake text before @ for the destination host or copy embedded credentials into a report.
  • Non-web schemes: I review these separately rather than pretending every address follows HTTP rules.

The MDN hostname documentation makes the IP-address distinction explicit. It also describes internationalized hostname conversion. I therefore don't assume a changed-looking hostname is damaged, but I do keep the source value so I can compare the two representations without guessing.

For missing schemes, consistency matters more than clever guessing. I record whether I added https:// as an interpretation step. That doesn't establish which protocol the destination actually supports. And I don't add it to arbitrary text merely because the text contains a dot.

What mistakes should I avoid when cleaning extracted domains?

My biggest rule is to preserve the source. A domain list is a reduced view of your URLs, not a replacement for them. Once you discard paths, queries, and subdomains, you may no longer have enough information to understand why an entry appeared.

  1. I extract before deduplicating at domain level. Different page URLs can produce the same hostname.
  2. I choose hostname or registered-domain grouping before removing repeated output lines.
  3. I inspect failures and unexpected changes before sorting the final list.
  4. I keep a mapping back to the original URLs if I need counts, evidence, or later page review.

For a plain hostname list, Remove Duplicate Lines is a useful next step. If I still need to compare complete addresses, I use URL Deduplicator instead. Those are different tasks: repeated websites and repeated page URLs aren't the same thing.

I also don't remove tracking parameters merely to extract a hostname. A parser separates the query from the hostname already. Cleaning the original URL first adds another transformation to check. I only change the source address when that change serves a separate, clear purpose.

I treat extraction as a reading operation, not a safety verdict. A successfully parsed hostname doesn't prove that a domain resolves, that its page loads, or that the destination is trustworthy. Public suffix recognition is not a substitute for those checks either.

Protect sensitive source URLs

Before pasting a private list into any online tool, I check how it handles input. I don't assume processing stays on my device unless that behaviour is documented or verified. Paths, query values, and embedded credentials can expose information even when the hostname itself looks harmless.

If I need to investigate where a link leads, Redirect Checker addresses a different question from extraction. The hostname written in the source URL isn't a promise about the final destination. I review unfamiliar entries before opening them, rather than treating a cleaned list as permission to visit everything.

My final check is practical: can I explain the output, account for rejected entries, and recover each original URL? If not, I stop before using the list for reporting or opening batches. A slightly longer review is preferable to a clean-looking result whose missing information I can't explain.

Questions people ask

How do I extract a domain from a URL?

I first decide whether I need the hostname or registered domain. For https://blog.example.com/article, the hostname is blog.example.com, while the registered domain is example.com. I use Domain Extractor to extract the address information, inspect the result, and apply suffix-aware grouping only if I need the registered domain.

How can I extract domains from a list of URLs in bulk?

I keep the original list, paste a short sample into Domain Extractor with one URL per line, and inspect the output before adding the rest. I check subdomains, ports, and failed entries. Then I copy the results separately and deduplicate only after deciding what counts as the same website.

How do I extract a domain from a URL in Excel?

For controlled URL text, I can use TEXTAFTER to remove the scheme and TEXTBEFORE to stop at the next slash. But I don't treat that as a complete parser. Ports, credentials, missing schemes, and queries without a preceding path need more handling. I keep the source column and review exceptions.

How do I extract a domain from a URL in Google Sheets?

I can use REGEXEXTRACT to capture the authority after an HTTP or HTTPS scheme, stopping before a path, query, or fragment. That equals the hostname only when credentials and ports are absent. I use a parser for mixed inputs and don't assume ISURL gives a definitive domain-validity answer.

How do I get the root domain without www or other subdomains?

I extract the hostname first, then use public suffix rules to find the registrable domain. Removing www handles only that particular prefix. It doesn't remove blog or support, and keeping the last two labels fails for example.co.uk. I preserve the original hostname whenever separate services may matter.

Can a URL host be an IP address or localhost instead of a domain?

Yes. I can extract an IP address as the hostname without finding a registered domain behind it. I also treat localhost and internal hostnames separately from public domains. They may be meaningful in development or internal lists, so I flag them rather than silently deleting or reshaping them.

What to do next

I start domain extraction by choosing the result, not by deleting pieces of text. Open Domain Extractor, paste a short sample, and compare its output with the hostname or registered domain you actually need. Keep your original URLs beside the results. Then process the rest, review failures, and remove duplicates at the right level. If example.co.uk becomes co.uk or a port remains in a hostname column, stop and fix the method before continuing. That's the workflow I'd use to get a useful list without throwing away details I might need later.

Sources I checked

Tools from this guide

Keep reading