URL vs URI: The Ultimate Guide to Understanding the difference between URL and URI

URL (Uniform Resource Locator) and URI (Uniform Resource Identifier) are both terms used to identify and locate resources on the internet. Despite being used interchangeably, there is a distinct difference between the two.
While a URL specifically provides the exact location of a resource on the internet, a URI can identify a resource in a broader sense and can include both its location (URL) and unique identifier (URN).
In this post, we will learn about the key differences between URL and URI and provides guidelines for choosing between them.

difference between url and uri
Difference between URL and URI

What is a URL?

A URL, or Uniform Resource Locator, is a series of characters that indicate the location of a resource on the internet. This URL allows you to directly access the file or resource by providing its exact location. URLs are commonly used to access websites and web pages but they can also point to other resources like images, videos, and files.

The URL employs a protocol, such as HTTP, HTTPS, or FTP, to access the resource over the internet. The URL is often referred to as the website’s address, which can be found in the address bar of a browser.

Syntax of the URL

The following is a Syntax of the URL:


We can divide the above URL into the following four parts:

  • http: The protocol being used in the URL. In this case, it is Hypertext Transfer Protocol (HTTP), which is a communication protocol used to transfer data on the internet.
  • ://: The separator between the protocol and the rest of the URL.
  • www.example.com: The domain name of the website. This is the name used to identify the website on the internet.
  • /index.html: The path to a specific resource on the website. In this case, it is the file index.html located at the root of the website.

Using a URL (Uniform Resource Locator), you can access various types of information and resources available on the internet, such as:

Type of ResourceExample
Web pages:HTML documents with text, images, videos, and other multimedia content
Images:JPEG, PNG, GIF, etc.
Videos:MP4, AVI, MOV, etc.
AudioMP3, WAV, etc.
Documents:PDF, Word, Excel, PowerPoint, etc.
APIs:Interfaces for accessing data and services from other websites and applications
Downloadable files:You can download files such as Software, music, games, etc. using URL.
Web-based applications:You can also access online tools and services such as email, social media, etc. using URLs.
Type of resources that can be access by using URLs

These are some of the common things you can access through a URL but the possibilities are endless as the internet continues to evolve and new resources are added all the time.

What is a URI?

A URI or Uniform Resource Identifier is a string containing characters that identify a physical or logical resource on the internet. URI can be either a URL or URN (Uniform Resource Name), but the term URI is used to refer to both of them. Although URI is used to identify resources, it doesn’t provide any information about the location of the resource.


Following is an example of a URI (Uniform Resource Identifier): urn:isbn:0-486-27557-4.

This URI is a URN (Uniform Resource Name) that provides a unique identifier for a specific book. The URN starts with urn: and then includes the namespace isbn and the identifier 0-486-27557-4.


The syntax for a URN is as follows:


Here, the NAMESPACE is a unique identifier for the type of resource being identified, and IDENTIFIER is a unique identifier for the specific resource.


The figure below shows sample URIs and their constituent parts.

URIs and their component
Source: wikipedia

How to convert URL to URI?

In C#, you can convert a URL to a URI by using the Uri class from the System namespace. Here is an example of how to convert a URL to a URI in C#:

using System;

namespace ConvertURLtoURI
    class Program
        static void Main(string[] args)
            string url = "https://www.example.com";
            Uri uri = new Uri(url);

What is a URN?

A URN (Uniform Resource Name) is a type of identifier used to uniquely identify a resource but does not specify its location. Unlike a URL (Uniform Resource Locator), a URN describes the identity of a resource rather than its location.

Example: URN

Here are a few examples of URNs with explanations:

  • ISBN (International Standard Book Number): A unique identifier assigned to a book by its publisher. The ISBN for “The Catcher in the Rye,” for example, is urn:isbn:0316769487.
  • urn:uuid: A URN that identifies a resource by a universally unique identifier (UUID). UUIDs are random numbers that are assigned to a resource to ensure that it is unique and can be easily referenced. For example, a UUID could be urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6.
  • urn:nbn: A URN used by the National Bibliographic Agency to identify resources in the library system. A resource in the library system, for example, could be identified by urn:nbn:de:101:1-2015020600223.

These are just a few examples of how URNs are used to identify resources in different ways, However, the overall purpose of a URN is to provide a unique identifier that can be used to reference a resource regardless of where it is located.

Key Differences Between URL and URI

  • Purpose: A URL is used to locate a resource on the internet whereas a URI is used to identify a resource.
  • Format: A URL must follow a specific format (e.g., http://www.example.com/index.html) while a URI can follow any format as long as it is unique (e.g., urn:isbn:0-284-56879-3).
  • Accessibility: A URL can be directly accessed, while a URI cannot be directly accessed.
  • Types: A URL is a specific type of URI whereas a URI can be either a URL or URN.
  • Protocol information: A URL includes a protocol like HTTP or HTTPS whereas a URI does not specify any protocol information.
  • Relationship: A URL is a Type of URI whereas URI is a Superset of URLs.

Examples of URL and URI in C#

The following is a sample example of how to create a URL and URI in C#:

// Example of creating a URL in C#
string url = "https://www.example.com/index.html";
Uri myUrl = new Uri(url);

// Example of creating a URI in C#
string uri = "urn:example:com:index.html";
Uri myUri = new Uri(uri);


To summarise, while URLs and URIs may appear to be similar, they serve different purposes and have different characteristics. URLs are used to browse the internet, whereas URIs are used to identify resources. Understanding the difference between these two types of identifiers is important for anyone working with internet resources.


Here are some frequently asked questions (FAQs) related to URL and URI.

Q: What is the difference between URL and URI?

URL (Uniform Resource Locator) refers to the exact location of a resource on the internet. A URL provides information about the resource location as well as the protocol used to access it.
A URI (Uniform Resource Identifier) identifies a resource on the internet without providing information about its location. It can be either a URL or a URN (Uniform Resource Name).

Q: When should you use a URL?

You can use a URL, when you need to access a specific internet resource, such as a website, web page, image, or video. You can use URL to provide the exact location of a resource that requires a specific protocol to access it, such as HTTP/HTTPS or FTP.

Q: When should you use URI?

You can use URI, When you need to identify a resource without providing information about its location. You can also use URI to provide a unique identifier for a resource but not directly access it, or to use a specific naming scheme for a resource, such as URN (Uniform Resource Name).

Q: What is the format of a URL?

A URL must follow a specific format, such as http://www.example.com/index.html. It consists of a protocol, a domain name, and a path to a specific resource on the website.

Q: What is the syntax for a URN?

The syntax for a URN is urn:NAMESPACE:IDENTIFIER, where NAMESPACE is a unique identifier for the type of resource being identified and IDENTIFIER is a unique identifier for the specific resource.

References:geeksforgeeks-URLVS URI , wikipedia- Uniform Resource Identifier

You might also like:

We would love to hear your thoughts on this post. Please leave a comment below and share it with others.

Shekh Ali
4.5 2 votes
Article Rating
Notify of

Inline Feedbacks
View all comments