Understanding URL Structure: Scheme, Host, Path, Query, and Fragment
A URL is a string that represents the "address" of a resource on the web. It may look like a complicated run of symbols, but it actually breaks down into meaningful parts: scheme, host, path, query, and fragment. This article explains URL structure step by step, from the role of each part to percent-encoding and the difference between absolute and relative URLs.
You almost certainly see strings like "https://waza.tools/tools/url-parser/?lang=en#result" in your browser address bar every day. That is a URL. At first glance it looks like a complicated mix of symbols and letters, but it actually has a well-organized structure in which meaningful parts appear in a fixed order. This article explains what parts a URL is made of and what role each one plays.
What Is a URL
A URL (Uniform Resource Locator) is a string that uniquely points to the "location" of a resource on the web, such as a page, image, or API. Like a postal address used to deliver mail, it expresses in a single line "by which method, on which server, and at which location" to fetch something.
There is also a broader term, URI (Uniform Resource Identifier), but for the everyday "address you can access in a browser," it is fine to think of it as essentially a URL. The URL format is standardized in the RFC 3986 specification, and browsers and servers worldwide interpret it by the same rules. That is exactly why you can reach the same resource no matter which environment you access from.
The easiest way to see how a URL is broken down is to paste a real URL into the URL Parser and watch it split into its individual parts.
URL Structure: Five Parts
A typical URL is broadly made up of the following five parts.
https://example.com:443/path/to/page?key=value#section
| Part | Example | Role |
|---|---|---|
| Scheme | https | Specifies the protocol / method |
| Host | example.com | The target server (domain name) |
| Port | 443 | The connection port number on the server |
| Path | /path/to/page | The resource location on the server |
| Query / Fragment | ?key=value#section | Extra parameters and position |
Scheme
The scheme is the part at the start of the URL, such as "https," "http," "ftp," or "mailto," and it indicates "by which method to access the resource." It is usually followed by "://." For web pages, https, which encrypts the communication, is the current standard. Unencrypted http can be a security risk depending on the information involved.
Host
The host is the part like "example.com," the domain name that identifies the target server. In actual communication, this domain name is converted to an IP address by DNS, and a connection is made to the corresponding server. A subdomain such as "www." may be prefixed to it.
Port
The port is a number that represents the "connection point" on the server. http defaults to port 80 and https to port 443, and when these standard ports are used, the number is usually omitted. That is why most URLs you see day to day do not show a port number.
Path
The path, like "/path/to/page," indicates which location on the server the resource is at. Similar to a file system folder hierarchy, it expresses levels separated by slashes. Individual pages of a website are, in many cases, distinguished by this path.
The Role of the Query String and Fragment
After the path, you can add two more kinds of supplementary information: the query string and the fragment.
Query string (? and &)
The query string starts with "?" after the path and represents additional parameters passed to the server. The basic form is "key=value," and multiple parameters are joined with "&."
?keyword=url&page=2&sort=new
This example passes three parameters: keyword, page, and sort. It is often used to convey search words, filter conditions, or page numbers, so the same path can produce different results depending on the query. When a value includes non-ASCII characters or symbols, the percent-encoding described below is required.
Fragment (#)
The fragment starts with "#" at the end of the URL and points to a specific position within the page (a heading or element). For example, "#section" scrolls to that spot when the page opens.
An important characteristic of the fragment is that it is not sent to the server and is handled only on the browser side. While the query string is a "condition" passed to the server, the fragment is purely a "position within the page" specified on the client. Keeping this distinction in mind makes the difference easy to organize. The URL Parser lets you confirm such query and fragment extraction at a glance.
How Percent-Encoding Works
A URL has a restriction: only letters, digits, and a few symbols can be used as-is. When you want a value to contain spaces, non-ASCII characters, or symbols that carry special meaning in a URL such as "&," "?," or "#," you need a conversion called percent-encoding (URL encoding).
This works by converting the target characters into bytes and representing each byte as "%" followed by a two-digit hexadecimal number. For example, a space becomes "%20," and the Japanese character "あ" becomes "%E3%81%82" in UTF-8.
- Encoding: converting characters that cannot be used as-is into the "%XX" form.
- Decoding: converting the "%XX" form back into the original characters.
Encoding is essential when placing a search keyword into a query string or generating links correctly. If you forget to encode, an "&" or "#" inside a value can be mistaken for a delimiter, and the URL may not be interpreted as intended. When you want to check whether a string is correctly encoded or decoded, try converting it in the URL Encoder and compare the results. You can see exactly what sequence of "%XX" a string containing non-ASCII characters becomes.
Absolute URLs vs. Relative URLs
URLs come as absolute URLs, which include all parts, and relative URLs, which omit some parts and indicate only the position relative to the current location.
| Absolute URL | Relative URL | |
|---|---|---|
| Example | https://example.com/blog/article | /blog/article, ../article |
| Scheme / host | Included | Omitted |
| Basis | Location fixed on its own | Resolved against the current page |
An absolute URL includes everything from the scheme to the path and, on its own, points to the same resource from anywhere in the world. Absolute URLs are required for links to external sites and for URLs shared off-page, such as in email or social media.
A relative URL omits the scheme and host and is interpreted based on "the location of the page you are currently viewing." If it begins with a slash, like "/blog/article," it is a position from the site root; if it begins with "../," like "../article," it points one level up. For links within the same site, relative URLs have the advantage that you do not need to rewrite them even if the domain changes.
Breaking Down a URL in Practice
Everything covered so far sticks much faster once you break down a real URL by hand. Copy one URL from your browser's address bar and try mapping it, from the front, in the order "scheme," "host," "port," "path," "query," and "fragment." The trick is to use the delimiter symbols as markers: what comes before "://" is the scheme, up to the first "/" is the host (and port), up to "?" is the path, up to "#" is the query, and what follows is the fragment.
That said, splitting a long URL with many parameters by hand is tedious. That is where the URL Parser comes in handy. Just paste a URL and it automatically breaks it into parts and lists them, so you can intuitively grasp which symbol marks the boundary of each part. You can also see the query string expanded into its individual keys and values.
In addition, when you want to put a value containing non-ASCII characters or symbols, such as a search keyword, into a query, percent-encode that value with the URL Encoder before embedding it. Comparing the string before and after encoding makes it clear how "あ" becomes "%E3%81%82" and a space becomes "%20." Actually trying both breaking down and converting with your own hands is the fastest path to understanding URL structure.
A URL is a logically structured string in which the parts scheme, host, port, path, query, and fragment appear in a fixed order. Once you grasp the role of each part and how percent-encoding works, many web-related tasks, from creating links and using APIs to tracking down the cause of problems, become much easier.
Please note that this article is intended to provide general information. The details of URL specifications and behavior may differ by environment or implementation, so make your decision after checking the latest official information.
FAQ
What is a URL?
A URL (Uniform Resource Locator) is a string that uniquely points to the "location" of a resource on the web, such as a page, image, or API. Like a postal address, it expresses in one line by which method, on which server, and at which location to fetch something. It is made up of parts: scheme, host, port, path, query, and fragment.
How do the query string and fragment differ?
The query string starts with "?" and joins "key=value" pairs with "&"; it passes extra parameters to the server, used for search conditions or page numbers. The fragment starts with "#" and points to a specific position within the page. A key difference is that the fragment is not sent to the server and is handled only by the browser.
Why is percent-encoding necessary?
Because a URL can only use letters, digits, and a few symbols as-is. When you want a value to contain spaces, non-ASCII characters, or symbols that have special meaning in a URL such as "&," "?," or "#," you need percent-encoding, which represents each byte as "%" plus two hex digits. Forgetting it can make a symbol be mistaken for a delimiter so the URL is not interpreted correctly.
When should I use an absolute URL versus a relative URL?
An absolute URL includes everything from the scheme to the path and points to the same resource from anywhere on its own; it is required for links to external sites and for sharing in email or social media. A relative URL omits the scheme and host and is interpreted based on the current page. Relative URLs are convenient for links within the same site.
Are URLs pasted into the URL Parser or URL Encoder sent to a server?
WAZA TOOLS' URL Parser and URL Encoder run entirely in your browser, so the URLs or strings you enter are never sent to or stored on a server. They work on smartphones too, and you can parse, encode, and decode URLs as many times as you like, for free.