A long shopping link can hide a small mistake: the wrong host, a missing query value, or a fragment mixed into a parameter. When I explain how to split a URL into components, I start by separating those jobs instead of cutting at every slash. I built URL Parser for that kind of inspection, and I test my tools on a budget Android phone and a laptop. Here, I'll show you how I read the parts, check the output, and avoid changing the link by accident.
What are the main components of a URL?
I start with five broad parts: scheme, authority, path, query and fragment. That's the general structure described in RFC 3986. Not every address includes every part. For an ordinary web link, I then look inside the authority to identify the hostname, any credentials and any explicit port.
Here's the example I'll use: https://shop.example.com:443/shoes/running?color=blue&size=10&utm_source=newsletter#reviews. I deliberately included an explicit default port, several query parameters and a fragment. That gives you something useful to compare with parser output, including a detail a browser-style parser may normalize.
| Component | Example value | How I read it |
|---|---|---|
| Scheme | https | The scheme used for this address |
| Authority | shop.example.com:443 | The hostname and explicit port in this example |
| Hostname | shop.example.com | The domain name, including the shop subdomain |
| Explicit port | 443 | The written port, which is the default for HTTPS |
| Path | /shoes/running | The resource path |
| Query | color=blue&size=10&utm_source=newsletter | Information supplied after the question mark |
| Fragment | reviews | Information supplied after the hash character |
Why I separate values from their punctuation
I keep the boundary marks separate in my explanation. The query begins after ?, and the fragment begins after #. But an API may return those marks as part of a property. JavaScript's search and hash properties include them; Python's query and fragment fields don't. Different output labels don't necessarily mean the tools disagree about the address.
How do I split a URL online with URL Parser?
For a single public address, I use URL Parser rather than picking through a long string by hand. I keep the original nearby so I can compare the input with the separated values. My aim is inspection first. I don't remove parameters, decode the whole address or rewrite the path before I understand what each part does.
- Open URL Parser and paste a complete public URL into its URL input.
- For practice, use the shop.example.com example above rather than a private account link.
- Include https:// so the example is an absolute web address.
- Inspect the component output alongside the original.
- Read the scheme and hostname first.
- Then compare the path, query and fragment without editing their values.
- Check any difference before treating it as an error.
- An explicit default port may disappear in browser-style output.
- A query field may include its leading question mark, depending on the output format.
- Use the component that answers your question, and keep the full original for reference.
Tip from me: I use invented public examples for learning. Don't paste a password, access token or private query value into an online tool unless you've checked its data handling. I'm not claiming a browser-only processing guarantee here.
If you only need the domain portion, I'd choose Domain Extractor instead. If you need to inspect the whole address, stay with URL Parser. That distinction saves you from discarding the path or query before you've checked the part that's actually causing trouble.
What is the difference between host, hostname and domain?
I don't use these words as exact substitutes. A complete URL can contain a scheme, authority, path, query and fragment. A domain is only one possible part of that address. And a web address can use an IP address rather than a domain name, so calling every host a domain creates confusion.
How I read host and hostname in JavaScript
In JavaScript's URL interface, hostname excludes the port. The host property includes the port when a non-default port remains in the parsed address. I pay attention to that qualifier because a default port can be normalized away. For HTTPS, an explicitly written :443 may therefore be absent from both host and port output.
- I read shop.example.com as the hostname in the running example. The shop label is a subdomain of example.com.
- I read the authority as the larger section that can contain credentials, a hostname or IP address, and an optional port.
- I expect HTTP to use port 80 and HTTPS to use port 443 by default. An omitted port doesn't mean no port is used.
I also check for credentials before trusting my first visual impression. Credentials can appear before the host in an authority, but including usernames and passwords in URLs is deprecated because of security concerns. A familiar-looking word somewhere in the address isn't enough. I want the parser's actual hostname, not a guess based on whichever text catches my eye.
Where do the query string and fragment start?
In the running example, I read everything after ? and before # as the query. That gives me color=blue&size=10&utm_source=newsletter. Then I read reviews as the fragment. The URL can contain both components at once, but they do different jobs. I don't treat the fragment as another query parameter.
Why I don't assume every query is a simple map
Queries commonly contain key/value pairs separated by &, but the application decides what they mean. A parameter might control a filter, record campaign information or affect something else. Repeated names can also occur. If I turn every query into a structure that permits only one value per name, I can silently throw useful information away.
I treat the fragment differently because it isn't sent to the server in the HTTP request. It may identify a section within a document or carry information used by the page. MDN's explanation of URLs describes this distinction. Removing the fragment may change where you land within a page even though it doesn't change that request.
Tip from me: I preserve the full query before cleaning a link. If tracking is the part you want to remove, inspect it first, then use Tracking Parameter Remover. Don't delete every parameter just because the address looks long.
For that separate cleanup job, I use Tracking Parameter Remover. Parsing tells me where the query is. It doesn't, by itself, tell me which values the destination needs.
How do I extract URL components in JavaScript?
In browser code, I use the URL interface rather than a collection of string splits. MDN's URL reference documents the properties for reading and changing components. The following statements are plain JavaScript you can put in a console or script. I keep the example short so you can match each property to the earlier table.
const address = new URL('https://shop.example.com:443/shoes/running?color=blue&size=10&utm_source=newsletter#reviews');
- I read address.protocol for https: and address.hostname for shop.example.com.
- I read address.pathname for /shoes/running and address.search for ?color=blue&size=10&utm_source=newsletter.
- I read address.hash for #reviews. The leading hash character belongs to this property's output.
- I expect address.port to be an empty string here because 443 is the default HTTPS port, rather than expecting the original spelling to be preserved.
How I resolve a relative URL in JavaScript
For a relative reference, I supply a base: const address = new URL('/shoes/running?color=blue#reviews', 'https://shop.example.com/');. The base supplies the missing scheme and authority. Without a suitable base, the relative reference isn't enough for this constructor to produce the intended complete address. I choose the base deliberately instead of borrowing an unrelated page's context.
How do I split a URL into components in Python?
In Python, I start with urllib.parse.urlsplit(). It returns five fields: scheme, netloc, path, query and fragment. The Python urllib.parse documentation explains that netloc is the older name retained for compatibility. I read it as the network location or authority field, not as a synonym for just the domain.
from urllib.parse import urlsplit, urljoin; parts = urlsplit('https://shop.example.com:443/shoes/running?color=blue&size=10&utm_source=newsletter#reviews')
I can now inspect parts.scheme, parts.netloc, parts.path, parts.query and parts.fragment. The query and fragment don't include their opening punctuation. Here, netloc preserves shop.example.com:443. That's a useful contrast with JavaScript's handling of the explicit default port, and a reason I don't expect every library's output to look identical.
To resolve a relative reference first, I use absolute = urljoin('https://shop.example.com/', '/shoes/running?color=blue#reviews'); parts = urlsplit(absolute). I keep resolution and splitting conceptually separate: urljoin supplies the address context, then urlsplit exposes its parts. Splitting a relative reference alone doesn't invent a missing hostname.
Tip from me: I don't use Python's successful parsing result as a safety check. Its documentation explicitly warns that urlsplit() and urlparse() don't validate inputs. Check the resulting scheme and host against your application's requirements before trusting them.
Which URL parsing method should I choose?
I choose based on the job, not on which method looks most technical. Reading a short address manually is useful for learning. An online parser helps me inspect a public link. Code makes more sense when parsing is part of an application or a repeatable task. The important thing is keeping each method's limits visible.
| My task | My choice | What I still check |
|---|---|---|
| Learn the parts of a simple address | Manual reading beside a parser result | Optional components and punctuation |
| Inspect a public link online | URL Parser | Sensitive values before pasting |
| Extract components in browser code | JavaScript URL | Base URL and normalized output |
| Extract components in Python | urllib.parse.urlsplit() | Validation requirements and netloc |
| Check address structure separately | URL Validator | Parsing isn't proof of reachability |
| Investigate a redirect | Redirect Checker | A parsed host isn't the whole redirect journey |
I also separate three questions: can I parse it, does it meet my rules, and does it work as expected? URL Validator fits the structure-checking task. Redirect Checker fits redirect investigation. Neither task should be confused with simply extracting the pathname or hostname.
For code that behaves like a browser, I consult the WHATWG URL Standard. For Python-specific behavior, I use Python's documentation. Those references serve different purposes. Treating generic URI syntax, browser parsing and a language library as identical is an easy way to write a misleading test.
What URL splitting mistakes should I avoid?
My strongest advice is to avoid building a general URL parser by splitting on punctuation. A slash, colon or at sign only makes sense in context. Credentials, IPv6 addresses and different schemes make quick string rules fragile. Percent-encoded characters add another trap if you decode everything before finding the real component boundaries.
- I parse before decoding. Otherwise, an encoded delimiter can become punctuation that my later code mistakes for a structural boundary.
- I preserve repeated query names. Keeping only one value can change the information represented by the original query.
- I don't split a host at every colon. An IPv6 address isn't safely handled by that rule.
- I don't assume every scheme is followed by ://. A mailto: address doesn't have the same shape as an HTTPS shopping link.
- I don't call a parsed link safe. Parsing exposes structure, not trustworthiness, access rights or server availability.
When I need to read an encoded value, I isolate that component first and then use URL Decoder for the separate decoding task. I retain the original spelling beside the decoded text. That way, a clearer human-readable value doesn't accidentally replace the address I'm trying to investigate.
And I resist deleting things just because I don't recognize them. An unfamiliar parameter isn't automatically tracking. A fragment isn't automatically useless. I first identify the component, then check its purpose, and only then consider changing it.
How do I check a URL after splitting it?
Once I have the parts, I compare them with the job the link is supposed to do. If I'm investigating the wrong page, I inspect the path and query. If I'm checking the destination, I inspect the hostname first. If the page opens at the wrong section, I inspect the fragment rather than blaming the server query.
- I confirm that the scheme and hostname match the intended destination.
- I compare the path with the intended resource without casually changing its spelling.
- I inspect query names, values and repeated entries before removing anything.
- I keep the fragment if the recipient needs the page section it identifies.
- I keep the original URL so every edit can be compared or undone.
I stop short of promising that a tidy result will load. The destination may require access, redirect elsewhere or be unavailable. What parsing gives me is a reliable starting point for the next check. That's enough to be useful, provided I don't mistake a neatly separated address for proof that everything behind it is working.
Questions people ask
What are the main components of a URL?
I describe the broad components as scheme, authority, path, query and fragment. Some are optional. For an HTTP or HTTPS address, I also inspect the authority's hostname and optional port. I keep those levels separate because a hostname isn't the whole authority, and a domain isn't the whole URL.
What is the difference between a URL and a domain?
I think of the URL as the complete address and the domain as one possible part within it. In https://shop.example.com/shoes, the hostname is shop.example.com and the path is /shoes. A web URL can also use an IP address, so I don't assume every address contains a domain name.
What is the difference between a URL's host and hostname?
In JavaScript's URL interface, I use hostname when I want the name or IP address without a port. The host property includes a port when one remains after parsing. I also account for normalization: an explicitly written default HTTPS port of 443 can disappear from the parsed output.
Is the fragment after # sent to the web server?
No. I treat the fragment as client-side information because it isn't sent in the HTTP request. It can identify a section in a document or be used by page code. I still preserve it when sharing a link if that section or page behavior matters to the reader.
How do I parse a relative URL?
I supply the missing context with a base URL. In JavaScript, I pass the relative reference and base to new URL(). In Python, I resolve with urljoin() before using urlsplit(). I choose the base carefully because resolving the same relative reference against a different base can produce a different destination.
Is splitting a URL with string methods reliable?
I wouldn't use raw string splitting as a general parser. Credentials, encoded delimiters, IPv6 addresses and schemes without :// break simple assumptions. I use manual reading to understand a straightforward example, but I choose a standards-aware parser when code must reliably identify component boundaries across different kinds of input.
What to do next
I would start with one public example, not a private login or account link. Open URL Parser, paste the address, and compare the scheme, hostname, path, query and fragment with the original. Keep encoded values and repeated parameters intact while you inspect them. If you're writing code, use JavaScript's URL interface or Python's urlsplit(), and supply a base when resolving a relative reference. Then make your next check deliberately: structure, destination behavior or safety. Splitting the address answers what its parts are. It doesn't answer every question about the page behind it.