I hate to use Excel formulas to extract domain names from URLs and the same goes for extracting domains from URLs with Google Sheets because it’s so complex and adds unnecessary friction.

It requires dealing with complex formulas and regex but sometimes I had no choice but to use Google Sheets or Excel to get domain names out of a list of URLs.

To those who need to get a domain from a URL, this guide is for you:

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.

My URL list where I want to extract the domains from
My URL list where I want to extract the domains from

Then paste this formula into another cell to extract the domain names from your list of URLs.

Here is my formula: =SUBSTITUTE(LEFT(MID(B5,FIND("//",B5)+2,LEN(B5)),FIND("/",MID(B5,FIND("//",B5)+2,LEN(B5))&"/")-1), "www.", "")

My formula to extract domain names from URLs
My formula to extract domain names from URLs

And press “ENTER” to apply the formula to your cell.

Extracted domain from URL
Extracted domain from URL

How This Formula Works:

  • FIND("//", B5)+2
    • Locates the position of :// and skips past it (e.g. in https://)
    • This sets the starting point of the domain portion
  • MID(B5, FIND(...) + 2, LEN(B5))
    • Extracts everything after :// to the end of the URL
    • This includes the domain, path, etc.
  • FIND("/", ..., &"/")
    • Finds the **first / after the domain
    • The &"/" ensures it works even if there’s no / in the original URL (prevents #VALUE error)
  • LEFT(..., ..., -1)
    • Trims the domain-only portion (before the first /) from the MID result
  • SUBSTITUTE(..., "www.", "")
    • Finally strips out "www." from the domain (if present)

Finally, drag down the bottom right corner to apply the formula to your entire list of URLs, as shown in this picture:

Domains extracted from my entire list
Domains extracted from my entire list

💡 Don’t Forget: If you’re a Google Sheets user you can also apply this formula and get the same results.

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.

The function isn't overly technical, and you can modify it as needed.

Start by importing or pasting a list of URLs to Column A.

My list of URLs in Google Sheets
My list of URLs in Google Sheets

Add this formula in column B beside the URLs.

=REGEXREPLACE(A2,"https?\:\/\/|www\.|\/.*|\?.*|\#.*","")

My “REGEXREPLACE” formula to extract domains in Google Sheets
My “REGEXREPLACE” formula to extract domains in Google Sheets

Press “ENTER” to apply the formula to your cell.

The domain name I extracted from a URL in Google Sheets
The domain name I extracted from a URL in Google Sheets

How This Formula Works

  • REGEXREPLACE(...)
    • Uses regular expressions to identify and replace parts of the text (in this case, the URL).
    • Each pattern separated by | is an element to be removed.
  • https?\:\/\/
    • Removes both http:// and https://
    • s? means the s is optional**, so it matches both protocols
    • \: and \/ escape the colon and slashes (regex syntax)
  • www\.
    • Removes www. from the domain (escaped dot \. means literal dot)
  • \/.*
    • Removes everything starting from the **first forward slash /
    • .* means “everything after”, so it strips the path from the URL
  • \?.*
    • Removes query parameters, like ?ref=newsletter
    • \? escapes the ? character
  • \#.*
    • Removes fragments/anchors, like #section3
    • \# escapes the # symbol
  • Final Result:
    • Leaves behind a clean, core domain like datablist.com

Then drag the bottom right corner to apply the formula to your entire list.

Extracted domains from my URL list in Google Sheets
Extracted domains from my URL list in Google Sheets

Voila!

Interesting Fact: Regex replace isn't only for Google Sheets — it works in Excel as well, but only if you have the new version or use Excel in your browser.

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 how you can use AI to extract domains from URLs in less than a minute.

For this example, I'll use Datablist.com, an AI-Copilot for data management.

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.

Datablist’s homepage
Datablist’s homepage

Now import your file with the URLs you want to extract the domains from.

Datablist’s start page
Datablist’s start page

After uploading your file, click "Edit" and select "AI Editing"

Datablist’s user interface and editing features
Datablist’s user interface and editing features

Type in a prompt or use my prompt below this picture, and the AI will do everything for you.

My prompt to extract domains from URLs
My prompt to extract domains from URLs

Here’s the prompt to get the domain names from the URL list:

Extract all the domains from this list without the subdomains. 

Use {{URL}} as a reference.

Before applying any changes, the AI will show you a preview so you can verify the results.

Once you've previewed your items, click "Run on items" to apply the change on all items.

AI-generated preview of the extracted domains from my URL list
AI-generated preview of the extracted domains from my URL list

Voilà, the script has run and extracted all domain names from my list of company URLs.

Run script to extract all domains from my URLs
Run script to extract all domains from my URLs

Here’s what the result looks like:

Extracted list of domain names from complex structured URLs
Extracted list of domain names from complex structured URLs

Conclusion

Excel formulas and Google Sheets scripts work well for extracting domains from URLs and many other use cases, however they can be complex. Since completing these tasks with AI takes less than a minute, I recommend everyone try AI first.

Frequently Asked Questions About Domain Extraction

What are the best tools to extract domains from a list of URLs?

Three powerful methods exist for domain extraction: Excel formulas for spreadsheet users, Google Sheets' REGEXREPLACE function for cloud-based work, and AI-powered tools that automate the process entirely.

How do I clean up messy URLs in a spreadsheet?

Domain cleanup can be achieved through Excel formulas that strip away "http://", "www.", and everything after the first forward slash. For Google Sheets users, the REGEXREPLACE function offers a powerful way to clean URLs automatically.

Is there a way to bulk extract domain names from multiple URLs?

Yes, bulk domain extraction can be done using spreadsheet formulas or AI tools. While spreadsheet methods work well for smaller lists, AI tools can process thousands of URLs in seconds with higher accuracy.

How can I remove subdomains from URLs?

Domain extraction formulas and regex patterns can be configured to remove subdomains, leaving only the main domain name specifically. This is particularly useful when analyzing website data or cleaning up URL lists.

What's the quickest way to get website names from long URLs?

AI-powered tools provide the fastest solution for extracting website names from URLs, processing entire lists in seconds. For those who prefer manual methods, spreadsheet formulas can also automate this process effectively.

How do I extract domains without any technical knowledge?

Modern AI tools have made domain extraction accessible to everyone, requiring no technical expertise. Just upload your URL list and let the AI handle the extraction process automatically.