New: ready-to-use spreadsheet templatesExplore the collection  →
PASTE-READY RECIPE

Extract the Domain from a URL in Google Sheets

Turn a full URL into a clean hostname without the protocol, path or query string.

Written by PhilisPublished July 27, 2026Updated July 27, 2026Interactive example
QUICK ANSWER

The formula and where it fits.

Turn a full URL into a clean hostname without the protocol, path or query string. Use =REGEXEXTRACT(A2,"^(?:https?://)?(?:www\.)?([^/]+)"), then replace the sample ranges with the columns in your sheet.

The captured group stops at the first slash after the hostname.

  1. Put the source data under one header row.
  2. Paste the formula into an empty result cell.
  3. Change the ranges and criteria to match your sheet.
  4. Check the result against one row you can verify manually.
TRY IT

Edit the table.
Watch the result change.

EDITABLE INPUT DATA
fx=REGEXEXTRACT(A2,"^(?:https?://)?(?:www\.)?([^/]+)")
A
1URL
2
3
4
FORMULA OUTPUTexample.com · sheetsteps.com · docs.google.comRecalculates from the input cells above
VARIATIONS

Use the version that fits your sheet.

01

Keep subdomains

=REGEXEXTRACT(A2,"^(?:https?://)?([^/]+)")

Keeps www or another subdomain.

02

Remove www only

=REGEXREPLACE(REGEXEXTRACT(A2,"^(?:https?://)?([^/]+)"),"^www\.","")

Keeps other subdomains.

03

Whole column

=ARRAYFORMULA(IF(A2:A="","",REGEXEXTRACT(A2:A,"^(?:https?://)?(?:www\.)?([^/]+)")))

Applies the extraction down the column.

COMMON ERRORS

When the result looks wrong.

A URL contains leading spaces

Wrap the source in TRIM.

A protocol other than HTTP is present

Extend the opening pattern when mailto or ftp inputs are expected.

QUESTIONS

Answers before you paste.

A URL contains leading spaces

Wrap the source in TRIM.

A protocol other than HTTP is present

Extend the opening pattern when mailto or ftp inputs are expected.

MAKE IT YOURS

Change the ranges, labels or criteria.

Send this recipe to the SheetSteps assistant and describe how your columns are arranged.

Adjust this formula