Arte SheetsLearn. Try. Understand.

Text & String Formulas

Extract a Simple Hostname Pattern from a URL in Excel

Extract a hostname from a limited set of simple HTTP(S) URL examples, and understand the cases that need a proper URL parser.

A limited delimiter example, not a complete URL parser

SEO backlink exports and analytics referral logs mix bare domains ("https://example.com"), deep paths ("https://www.shop.example.com/cart?id=9"), HTTP links, and custom staging ports ("http://api.example.com:8080/v1"). Calling FIND("/", A2, 9) crashes with #VALUE! whenever a root URL has no trailing slash. This text formula handles only the illustrated simple HTTP(S) domain/path forms. It is not a general URL parser: query-only URLs, fragments, user-info, IPv6 addresses, and names containing www. away from the start can be parsed incorrectly. Do not use the result to enforce a security policy.

Appending a sentinel "/" inside FIND("/", clean_url & "/") guarantees FIND ALWAYS succeeds—even on slashless bare domains. Stripping "https://", "http://", leading "www.", anything after "/", and anything after ":" in sequence extracts clean hostnames across every URL variation.

Raw Analytics Referral URLProtocol & www. StrippedClean Hostname Returned
"https://www.sheets.arte-soft.com/en/guides?src=nav"sheets.arte-soft.com/en/..."sheets.arte-soft.com"
"http://api.vendor.io:8443/v2/status"api.vendor.io:8443/v2/..."api.vendor.io" (Port Stripped)
"https://example.org" (No Trailing Slash)example.org + "/" Sentinel"example.org" (Zero #VALUE. Crash)

Clean Domain / Hostname Stripping Protocol, www., Port & Path

Removes https:// and http://, slices before the first "/" (using & "/" sentinel) and before ":" (using & ":" port sentinel), and strips leading "www.".

=IF(TRIM(A2) = "", "", SUBSTITUTE(LEFT(LEFT(SUBSTITUTE(SUBSTITUTE(LOWER(TRIM(A2)), "https://", ""), "http://", ""), FIND("/", SUBSTITUTE(SUBSTITUTE(LOWER(TRIM(A2)), "https://", ""), "http://", "") & "/") - 1), FIND(":", LEFT(SUBSTITUTE(SUBSTITUTE(LOWER(TRIM(A2)), "https://", ""), "http://", ""), FIND("/", SUBSTITUTE(SUBSTITUTE(LOWER(TRIM(A2)), "https://", ""), "http://", "") & "/") - 1) & ":") - 1), "www.", "", 1))

Check Only for a Literal HTTPS Prefix

This checks the text prefix only. It does not verify the domain, certificate, destination or safety of a link.

=IF(TRIM(A2) = "", "Blank URL", IF(LEFT(LOWER(TRIM(A2)), 8) = "https://", "HTTPS Prefix Present", "No HTTPS Prefix"))

Try the example

Use the original values or change them to test your understanding.

Further reading