Manually parsing high-volume web traffic data can quickly overwhelm SEO and marketing analysts. While organizations often allocate dedicated development funding sources for enterprise-level data cleaning tools, immediate, cost-effective alternatives are essential. Utilizing native Excel formulas grants analysts complete autonomy over data segmentation without relying on IT support.
As a minor stipulation, these text-manipulation formulas assume your URLs contain consistent protocol prefixes (e.g., "https://"). For instance, a robust formula will flawlessly split https://example.com/resources into the domain example.com and the path /resources. Below, we outline the exact step-by-step formulas to execute this split.
When working with large search engine optimization (SEO) audits, digital marketing reports, or web analytics exports, you will frequently find yourself staring at a column containing thousands of full URLs. To perform meaningful data analysis-such as grouping pages by directory, analyzing subfolder performance, or mapping redirects-you need to break these URLs down into their core components: the Domain and the Path.
For example, if you have the URL https://www.example.com/blog/seo-tips?utm_source=newsletter, you may want to extract:
https://www.example.com (or simply example.com)/blog/seo-tipsIn this comprehensive guide, we will explore several ways to split URLs in Excel, ranging from classic formulas compatible with older Excel versions to modern Excel 365 dynamic array functions, and even a quick look at Power Query for bulk processing.
Before diving into the formulas, it helps to understand the structural pattern of a URL. A standard URL consists of:
http:// or https://www.example.com/blog/seo-tips (indicates the specific page structure)?utm_source=newsletter (optional tracking data)The boundary between the domain and the path is almost always the third forward slash (/) in the URL, assuming the URL starts with a protocol. Recognizing this pattern is the secret to constructing our Excel formulas.
If you want to keep the protocol (e.g., https://) attached to your domain, you need a formula that finds the third slash and extracts everything before it. If the URL does not have a third slash (meaning it is a home page like https://example.com), the formula must handle this gracefully without throwing an error.
If you are using Excel 365 or Excel 2021 and later, you have access to the powerful TEXTBEFORE function. This makes extracting the domain incredibly simple:
=TEXTBEFORE(A2, "/", 3, , , A2)
A2: The cell containing your raw URL."/": The delimiter we want to look for.3: Tells Excel to look for the 3rd instance of the delimiter (the slash directly following the domain)., , , A2: These optional arguments instruct Excel on what to do if a 3rd slash is not found (for instance, on homepages like https://example.com). It simply returns the original value in A2 instead of a #N/A error.If you are working on an older version of Excel, you can achieve the exact same result using a combination of the LEFT and FIND functions:
=LEFT(A2, FIND("/", A2 & "/", 9) - 1)
A2 & "/": By appending a slash to the end of the URL, we prevent the formula from crashing with a #VALUE! error if the URL has no trailing slash.FIND("/", A2 & "/", 9): This searches for a slash starting from the 9th character. Starting at index 9 safely bypasses the slashes in http:// (index 6 and 7) or https:// (index 7 and 8). The first slash it finds after character 9 will be the one separating the domain and path.LEFT(..., -1): This extracts all characters from the left up to, but not including, that slash.For clean reporting, you often want to strip away the https://, http://, and www. to leave only the naked root domain (e.g., example.com).
=LET(
CleanURL, SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, "https://", ""), "http://", ""), "www.", ""),
LEFT(CleanURL, FIND("/", CleanURL & "/") - 1)
)
LET function is used to create a variable called CleanURL to keep our formula readable.SUBSTITUTE functions together to scrub out https://, http://, and www. from the raw URL.CleanURL & "/" ensures the formula returns the full cleaned domain safely.Once you have extracted the domain, getting the path is much easier. The path is everything that remains in the URL after the domain is removed.
If you have already extracted the domain in cell B2 (using Method 1), you can simply use the SUBSTITUTE function to remove the domain from the original URL in A2:
=SUBSTITUTE(A2, B2, "")
If A2 is https://example.com/blog/article and B2 is https://example.com, this formula replaces the domain string with nothing, leaving you cleanly with /blog/article.
If you want to extract the path directly from the raw URL in one step without referencing a secondary "domain" column, you can use TEXTAFTER:
="/" & TEXTAFTER(A2, "/", 3, , , "")
TEXTAFTER(A2, "/", 3, , , ""): Grabs everything after the 3rd slash. If there is no 3rd slash (meaning it is a homepage), it returns an empty string ("")."/" &: Since the path usually begins with a forward slash, we prepend a slash to the front of the output to keep our URL structures standard (converting blog/article to /blog/article).Often, your raw URLs will contain tracking parameters like ?utm_source=google or ?ref=homepage. When analyzing content paths, you typically want to exclude these queries so that identical pages don't show up on separate lines in your reports.
If your extracted path is in cell C2, use this formula to strip away everything from the question mark (?) onwards:
=IFERROR(LEFT(C2, FIND("?", C2) - 1), C2)
FIND("?", C2): Searches for the question mark that initiates query parameters.LEFT(C2, ... - 1): Extracts everything to the left of the question mark.IFERROR(..., C2): If there is no question mark in the path, FIND will return an error. IFERROR catches this and safely returns the unmodified path.If you are dealing with datasets containing hundreds of thousands of rows, writing complex formulas can slow down your workbook. Excel's Power Query is built for this type of heavy lifting.
/), and choose Split at each occurrence of the delimiter. Click OK.Here is a quick summary table of the formulas discussed in this article to keep handy for your next SEO audit or reporting task:
| Goal | Excel 365 Formula | Legacy Excel Formula (Pre-2021) |
|---|---|---|
| Extract Domain with Protocol | =TEXTBEFORE(A2, "/", 3, , , A2) |
=LEFT(A2, FIND("/", A2 & "/", 9) - 1) |
| Extract Path Only | ="/" & TEXTAFTER(A2, "/", 3, , , "") |
=SUBSTITUTE(A2, B2, "") (Requires Domain in B2) |
| Clean Naked Domain | =LET(c, SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, "https://", ""), "http://", ""), "www.", ""), LEFT(c, FIND("/", c & "/") - 1)) |
N/A (Use combined nested SUBSTITUTE functions) |
| Remove Query Parameters | =TEXTBEFORE(C2, "?", , , , C2) |
=IFERROR(LEFT(C2, FIND("?", C2) - 1), C2) |
Splitting URLs into domains and paths is a fundamental skill for any marketer, SEO professional, or data analyst. While legacy formulas relying on LEFT, FIND, and SUBSTITUTE remain highly dependable, modern Excel 365 functions like TEXTBEFORE and TEXTAFTER make the process incredibly clean and intuitive. Choose the method that best matches your version of Excel and the size of your dataset to unlock deeper insights from your web data.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.