Formula example

Extract Domain from URL in Google Sheets

You have URLs in column A and want only the domain name for reporting or grouping.

Copyable formula

Google Sheets formula
=REGEXEXTRACT(A2, "^(?:https?:\/\/)?(?:www\.)?([^\/\?#]+)")

Sample data

URLResult
https://www.example.com/pricingexample.com
https://docs.google.com/spreadsheetsdocs.google.com
https://support.example.com/examplessupport.example.com

Formula explanation

  • The pattern ignores optional http, https, and www prefixes.
  • The captured group returns the text before the next slash, question mark, or hash.
  • REGEXEXTRACT returns the first match from the source cell.

Common errors

  • Some URLs may include ports or usernames that need a stricter pattern.
  • Cells without a matching URL return an error unless wrapped in IFERROR.
  • Excel may need TEXTAFTER/TEXTBEFORE or Power Query instead.

Build your own version

Use the deterministic builder for this pattern: REGEXEXTRACT Formula Builder.

Related formulas

FAQ

Can I remove www from every URL?

Yes. The provided formula ignores an optional www prefix.

Can I use this in Excel?

REGEXEXTRACT is for Google Sheets. Use Excel text functions or Power Query for Excel workflows.