To extract a domain from a URL, first decide which result you need. A hostname keeps subdomains, so https://shop.example.co.uk/products becomes shop.example.co.uk. A base domain removes the subdomain, leaving example.co.uk. The spreadsheet formulas below extract hostnames and remove a leading www.; the AI workflow shows how to request base domains and review the results.
This distinction matters when you group website visits or match companies. Removing everything before the last two dots would turn example.co.uk into co.uk, which is not a company domain. For one URL per row in Datablist, the built-in Data Extractor provides a domain action; the guide explains registrable domains and what happens when a row has no match.
An extracted domain is an identifier, not evidence of an active website. If you are refreshing a lead list, follow the bulk parked-domain check and review its website signals separately from email validity.
Choose the method that matches your output:
- How to extract domain names from a list of URLs in Excel.
- How to extract domain names from a list of URLs in Google Sheets.
- How to extract domain names from a list of URLs with AI instead of complex formulas or regex.
First Method: Extracting Domains from URLs with Excel Formula
Let’s begin! The first method is with Microsoft Excel. Import or paste your URLs into an Excel sheet.
Then paste this formula into another cell to extract the hostname from URLs that include http:// or https://.
Here is the formula: =SUBSTITUTE(LEFT(MID(B5,FIND("//",B5)+2,LEN(B5)),FIND("/",MID(B5,FIND("//",B5)+2,LEN(B5))&"/")-1), "www.", "")
And press “ENTER” to apply the formula to your cell.
How This Formula Works:
FIND("//", B5)+2- Locates the position of
://and skips past it (e.g. inhttps://) - This sets the starting point of the domain portion
- Locates the position of
MID(B5, FIND(...) + 2, LEN(B5))- Extracts everything after
://to the end of the URL - This includes the domain, path, etc.
- Extracts everything after
FIND("/", ..., &"/")- Finds the **first
/after the domain - The
&"/"ensures it works even if there’s no/in the original URL (prevents #VALUE error)
- Finds the **first
LEFT(..., ..., -1)- Trims the domain-only portion (before the first
/) from the MID result
- Trims the domain-only portion (before the first
SUBSTITUTE(..., "www.", "")- Removes
www.from the extracted text. It does not remove other subdomains.
- Removes
Finally, drag down the bottom right corner to apply the formula to your entire list of URLs, as shown in this picture:
💡 Check the input: This formula expects a URL with
//and uses the first/after it as the end of the hostname. Check URLs without a scheme and URLs with a query but no path before filling down. It extractsshop.example.comfromhttps://shop.example.com/page, notexample.com.
Second Method: Extracting Domains with a Regex Replace Formula in Google Sheets
The =REGEXREPLACE() function is built into Google Sheets, and it extracts domains from URLs.
This formula extracts the hostname and removes a leading www.. It does not remove other subdomains.
Start by importing or pasting a list of URLs to Column A.
Add this formula in column B beside the URLs.
=LOWER(REGEXREPLACE(REGEXEXTRACT(A2,"^(?:https?://)?([^/?#]+)"),"^www\.",""))
Press “ENTER” to apply the formula to your cell.
How This Formula Works
REGEXEXTRACTcaptures the text after an optionalhttp://orhttps://and before the first path, query, or fragment separator.REGEXREPLACEremoveswww.only when it starts the hostname.LOWERmakes matching results consistent.
For https://shop.example.co.uk/products, the result is shop.example.co.uk. Check URLs with ports, credentials, or unusual schemes separately before using the results as company match keys.
Then drag the bottom right corner to apply the formula to your entire list.
The screenshot shows the output for the sample list. For a base domain without subdomains, use a suffix-aware parser or the reviewed AI workflow below.
Third Method: Extracting Domain Names from URLs with AI
Now let’s see how you can use AI to shortcut this even further.
This video shows the AI Editing workflow for a list of URLs.
For this example, use Datablist to generate a transformation script and preview its output.
This doesn't require a formula or complex code — it works with just one prompt.
Step-By-Step Guide: How to Extract Domains from URLs Using AI
First, sign up for Datablist.
Now import your file with the URLs you want to extract the domains from.
After uploading your file, click Edit and select AI Editing
Enter a prompt that defines whether you need a hostname or a base domain.
Here’s the prompt to get the domain names from the URL list:
Read the URL in {{URL}} and write its base (registrable) domain to a new property. Remove a leading www and other subdomains, but keep the public suffix. For example, shop.example.co.uk becomes example.co.uk and app.example.com becomes example.com. Leave invalid or missing URLs blank so I can review them.
Before applying changes, review the preview. Include examples with www, another subdomain, a country-code suffix such as .co.uk, and a URL without a scheme. If a result is wrong, refine the prompt before running it on all items.
Once you've previewed your items, click Run on items to apply the change on all items.
Voilà, the script has run and extracted all domain names from my list of company URLs.
Here’s what the result looks like:
Conclusion
Use a spreadsheet formula when a hostname is enough. When you need a company-level base domain, test the AI output on several suffixes and edge cases before exporting the list.
Frequently Asked Questions About Domain Extraction
What are the best tools to extract domains from a list of URLs?
Use Excel or Google Sheets to extract hostnames. For base domains, use a suffix-aware parser or a reviewed AI transformation.
How do I clean up messy URLs in a spreadsheet?
Extract the hostname before the path, query, and fragment. Then decide whether to retain subdomains. Test URLs without schemes and those with country-code suffixes before applying the result to a full column.
Is there a way to bulk extract domain names from multiple URLs?
Yes. Fill a formula down a spreadsheet column, or import the URLs into Datablist and preview an AI Editing script before running it across the collection. Review a sample of the output before using it as a match key.
How can I remove subdomains from URLs?
The formulas in this guide only remove www.. Removing arbitrary subdomains requires identifying the public suffix first: shop.example.co.uk should become example.co.uk, not co.uk. Use a suffix-aware parser or preview an AI transformation on your own examples.
What's the quickest way to get website names from long URLs?
If you need the hostname, a spreadsheet formula is a quick option. If you need the base domain, use a tool that handles public suffixes and check its output on a representative sample.
How do I extract domains without any technical knowledge?
Import a URL column, give AI Editing the base-domain prompt above, inspect the preview, then run it on the full collection. Check unusual suffixes and invalid URLs before exporting.
















