FormulaCraft

How to extract the domain name from a URL in Excel and Google Sheets

Topic:Text manipulation

Heads up: Excel and Google Sheets do this differently.

Excel
=MID(A2,FIND("//",A2)+2,FIND("/",A2&"/",FIND("//",A2)+2)-FIND("//",A2)-2)
Google Sheets
=REGEXEXTRACT(A2,"//([^/]+)")

Verified example

Computed by a real spreadsheet engine on the sample data below.

URLDomain
https://www.example.com/path/to/page?query=123
http://subdomain.example.co.uk
https://example.org/

=MID(A2,FIND("//",A2)+2,FIND("/",A2&"/",FIND("//",A2)+2)-FIND("//",A2)-2)www.example.com

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Enter your URLs in column A starting from cell A2.
  2. 2In cell B2, enter the formula provided for Excel or Google Sheets.
  3. 3Drag the formula down to apply it to other URLs in column A.

Tips

Need the Google Sheets version instead? Open Sheets variant in workspace →

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

Frequently asked

What if my URLs don't have http:// or https://?

Modify the formula to account for URLs without these prefixes by adjusting the FIND function parameters.

Can I use this method for URLs with subdomains?

Yes, the formula extracts the main domain including subdomains. For just the root domain, additional parsing logic is needed.

Does this work with URLs that have query parameters?

Yes, the formula stops at the first slash after the domain, ignoring query parameters and paths.

More on Text manipulation

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: