Extract the Domain from a URL

Excel Formulas › Data Cleaning

All versionsMID

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.


Quick formula: domain from a URL:
=MID(url, FIND("//", url) + 2, FIND("/", url & "/", FIND("//", url) + 2) - FIND("//", url) - 2)
Find the // after the protocol, then take text up to the next slash — the domain.

Functions used (tap for the full reference guide):

The example

https://www.example.com/page → example.com.

AB
1URLDomain
2…example.com/pagewww.example.com

The formula

The formula:

=MID(url, FIND("//",url)+2, FIND("/", url&"/", FIND("//",url)+2) - FIND("//",url) - 2) // between // and next /

How it works

How it works:

  1. FIND("//", url) + 2 locates the start of the domain after the protocol.
  2. The next FIND("/", …) — appending a "/" so domains without a path still match — finds the end.
  3. MID grabs the text between them: the host (with or without www).
  4. 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

Live demo

Paste a URL.

Domain:

Variations

365 readable

TEXTBEFORE/AFTER:

=TEXTBEFORE(TEXTAFTER(url, "//"), "/")

Drop www

Clean host:

=SUBSTITUTE(domain, "www.", "")

Top-level part

After last dot:

=TRIM(RIGHT(SUBSTITUTE(domain,".",REPT(" ",99)),99))

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

📊
Download the free Extract the Domain from a URL practice workbook
A URL-domain sheet with the 365, drop-www, and TLD variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I extract a domain from a URL in Excel?
Take the text between // and the next /: =MID(url, FIND("//",url)+2, FIND("/", url&"/", FIND("//",url)+2) - FIND("//",url) - 2).
Is there a simpler way on Excel 365?
Yes: =TEXTBEFORE(TEXTAFTER(url, "//"), "/").
How do I remove www?
Wrap the result in SUBSTITUTE(domain, "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

Related formulas: Extract email domain · Extract between · Find text position

Function references: MIDFIND