A URL, or Uniform Resource Locator, is the address of a specific webpage or file on the internet. It typically consists of the protocol (such as http or https), the domain name (such as, and sometimes a path or file name (such as /about or index.html). A URL is used to locate and access a resource on the internet.

The different parts of a URL

A URL typically has several parts, including:


The protocol is the method used to access the resource. The most common protocols are http and https, but others such as ftp and file can also be used.

Domain name:

The domain name is the unique name that identifies a website on the internet. It typically includes a top-level domain (such as .com, .org, or .edu) and a second-level domain (such as example in


The path is the location of a specific file or page within the website's directory structure. It typically starts with a forward slash (/) and can include multiple subdirectories.

Query string:

The query string is a set of key-value pairs that are appended to the end of the URL. It is used to pass additional information to the server and is typically used in dynamic websites where the content of a page is determined by the query string.


The fragment is an optional identifier that can be used to specify a particular section of a web page. It starts with # and is not sent to the server.


Protocol: http
Domain Name:
Port: 80
Path: /path/to/file.html
Query String: ?query=string
Fragment: #fragment

Why and how to ASCII encode a URL

ASCII encoding is a method of representing text in computers and other devices that use the ASCII standard. ASCII encoding is used to convert non-ASCII characters in a URL into a format that can be transmitted over the internet.

There are several reasons why a URL might need to be ASCII encoded:

Special characters:

URLs can contain special characters such as spaces, ampersands, and non-English characters. These characters may not be properly transmitted over the internet if they are not encoded.


Encoding a URL can help to prevent cross-site scripting (XSS) attacks, where malicious code is injected into a website through a URL.


Some older systems or devices may not be able to handle non-ASCII characters in a URL, so encoding them ensures that the URL will be properly interpreted by these systems.

To ASCII encode a URL, a specific set of characters are converted into a percent symbol followed by two hexadecimal digits, which represent the ASCII code of the character. This encoding is also known as percent-encoding or URL encoding.

For example, the space character is encoded as %20 and the @ symbol is encoded as %40.

There are several libraries available in different programming languages that can be used to ASCII encode a URL, such as urllib.parse.quote() in Python, URLEncoder.encode() in Java, and Url.Encode() in C#.

HTML Basics