Pull the domain out of a full web address — strip the protocol and any path, leaving just "example.com". Useful for grouping traffic, deduping links, and tidying referrer data.
The example
https://www.example.com/page → example.com.
| A | B | |
|---|---|---|
| 1 | URL | Domain |
| 2 | …example.com/page | www.example.com |
The formula
The formula:
How it works
How it works:
FIND("//", url) + 2locates the start of the domain after the protocol.- The next
FIND("/", …)— appending a "/" so domains without a path still match — finds the end. MIDgrabs the text between them: the host (with or withoutwww).- To drop www, wrap in
SUBSTITUTE(…, "www.", "").
Append a sentinel slash for path-less URLs. The trick url & "/" guarantees there’s always a slash to find after the domain, so example.com (no path) and example.com/page both work in one formula. On Excel 365, TEXTBEFORE(TEXTAFTER(url, "//"), "/") does the same far more readably.
Try it: interactive demo
Paste a URL.
Variations
365 readable
TEXTBEFORE/AFTER:
Drop www
Clean host:
Top-level part
After last dot:
Pitfalls & errors
Append a slash. url & "/" handles URLs with no path.
No protocol breaks it. If "//" is missing, FIND errors — wrap in IFERROR or normalize first.
www stays. Strip it separately if you want the bare domain.
Practice workbook
Frequently asked questions
How do I extract a domain from a URL in Excel?
Is there a simpler way on Excel 365?
How do I remove www?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class