Excel Formulas to Split URLs into Domain and Path

📅 Aug 06, 2026 📝 Sarah Miller

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.

Excel Formulas to Split URLs into Domain and Path

Excel Formula to Split URL into Domain and Path

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:

  • Domain: https://www.example.com (or simply example.com)
  • Path: /blog/seo-tips

In 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.


Understanding the Anatomy of a URL

Before diving into the formulas, it helps to understand the structural pattern of a URL. A standard URL consists of:

  • Protocol: http:// or https://
  • Subdomain & Domain: www.example.com
  • Path: /blog/seo-tips (indicates the specific page structure)
  • Query Parameters: ?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.


Method 1: Extracting the Domain (Including Protocol)

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.

The Modern Excel 365 Formula

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)

How it works:

  • 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.

The Classic Excel Formula (Excel 2019 and Older)

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)

How it works:

  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.
  2. 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.
  3. LEFT(..., -1): This extracts all characters from the left up to, but not including, that slash.

Method 2: Extracting the Clean Domain (No Protocol, No WWW)

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).

The Formula:

=LET(
  CleanURL, SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, "https://", ""), "http://", ""), "www.", ""),
  LEFT(CleanURL, FIND("/", CleanURL & "/") - 1)
)

How it works:

  • The LET function is used to create a variable called CleanURL to keep our formula readable.
  • We chain multiple SUBSTITUTE functions together to scrub out https://, http://, and www. from the raw URL.
  • Once scrubbed, the domain is at the very beginning of the string. We then find the first slash in this clean string and extract everything before it. If there is no slash left, CleanURL & "/" ensures the formula returns the full cleaned domain safely.

Method 3: Extracting the Path

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.

The Simple "Subtraction" Method

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.

The All-in-One Path Formula (Excel 365)

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, , , "")

How it works:

  • 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).

Handling Edge Cases: Stripping Query Parameters

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.

To get a clean path without query parameters:

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)

How it works:

  • 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.

Bonus: Bulk URL Splitting Using Power Query

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.

  1. Select your data range, navigate to the Data tab, and click From Table/Range.
  2. Inside the Power Query Editor, right-click your URL column header and choose Duplicate Column (so you keep your original URLs intact).
  3. Select your duplicated column, go to the Transform tab, and click Split Column > By Delimiter.
  4. Select Custom as the delimiter, type a forward slash (/), and choose Split at each occurrence of the delimiter. Click OK.
  5. Power Query will split your URL into multiple columns (Protocol, empty space, Domain, and individual directories of your path).
  6. You can now rename, merge, or delete columns as needed, then click Close & Load to return your cleaned data to a new Excel sheet.

Quick Formula Cheat Sheet

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)

Conclusion

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.