URI vs URN vs URL : Key Distinctions Explained

Understanding the differences between URI, URN and URL

Abhirup Acharya
6 min readJun 27, 2023
https://www.wallpapertip.com/wpic/ihoRobh_web-url/

In the vast landscape of the internet, resources are identified and accessed through various types of identifiers. Among these identifiers, three commonly used terms are URI, URN, and URL. While they might seem similar at first glance, each has a distinct purpose and significance in web architecture.

This article aims to shed light on the nuances of these terms and explore their individual characteristics. By delving into their definitions, purposes, and practical examples, we will unravel the distinctions and provide clarity on when and how to use each identifier.

Let’s embark on a journey although short to demystify the concepts of URI, URN, and URL and discover their unique roles in the world of web identification.

URL

URL (Uniform Resource Locator) is a specific type of URI (Uniform Resource Identifier) that provides the web address or location of a resource on the internet. It is commonly used to specify the location of a webpage, file, or service. A URL provides a standardized format for accessing resources on the web. It serves as a crucial component in web browsing, linking, and communication over the internet.

A URL consists of several components that together define the address of the resource and the protocol used to access it. The typical structure of a URL is as follows:

Typical structure of a URL

Let’s break down the components of a URL:

  1. Scheme: It indicates the protocol or scheme used to access the resource, such as HTTP (Hypertext Transfer Protocol), HTTPS (HTTP Secure), FTP (File Transfer Protocol), or others.
    For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Scheme is http.
  2. Host: It specifies the domain name or IP address of the server hosting the resource. For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Host is www.example.com.
  3. Port: (Optional) It represents the specific port number on the host that the resource is accessed through. If no port is specified, it defaults to the standard port for the given scheme. The default port for HTTP is 80, while for HTTPS it is 443.
    For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Port is 8080.
  4. Path: (Optional) It denotes the specific location or directory on the server where the resource is located. It can include directories and file names. For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Path is /resource/page.html.
  5. Query Parameters: (Optional) They are additional parameters passed to the resource and are typically used in dynamic web applications. They appear after the path and are separated by the ? symbol. Query parameters are in the form of key-value pairs, like param1=value1&param2=value2.
    For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Query Parameters are param1=value1&param2=value2.
  6. Fragment Identifier: (Optional) It refers to a specific section or anchor within a webpage. The fragment identifier is indicated by the # symbol, followed by the identifier. It is commonly used to link to a specific section of a webpage.
    For example, in http://www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1, the Fragment Identifier is #section1.

If a URL has no authority (combination of Host + Port), the scheme and the rest of the URL are separated only by the colon :. A typical example of a URL without the authority part is the URL representing an email address, such as mailto:info@example.com.

A few examples of URLs are:
— https://www.example.com/index.html
— http://api.example.com/data
— ftp://ftp.example.com/files/document.pdf
— mailto:info@example.com
— mailto:user@example.com?subject=Hello&body=Hi%20there

URN

URN (Uniform Resource Name) is a type of URI (Uniform Resource Identifier) that is used to uniquely identify a resource, independent of its location. Unlike a URL, which specifies the address or location of a resource, a URN provides a persistent identifier that remains unchanged even if the resource is moved or its location changes.

The primary purpose of a URN is to serve as a long-lasting identifier for a resource, ensuring that the identifier remains valid over time. URNs are typically used for resources that require long-term persistence and consistent identification, such as academic papers, digital books, or cultural artifacts.

A URN typically follows the following structure:

  • URN: Indicates that the identifier is a Uniform Resource Name.
  • Namespace: Represents the unique namespace or identifier system that defines and governs the URN. It provides context and ensures the uniqueness of the identifier. Examples of namespaces include ISBN (International Standard Book Number) or ISSN (International Standard Serial Number).
  • Identifier: It is a string of characters that uniquely identifies the resource within the specified namespace. The identifier itself does not convey any information about the location or access method for the resource.

Here are a few examples of URNs:

  • urn:isbn:0-486-27557-4: A URN identifying a book with the given ISBN number.
  • urn:ietf:rfc:3986: A URN identifying an RFC (Request for Comments) document with the specified number.
  • urn:oid:2.16.840: A URN identifying an object using an OID (Object Identifier) in a specific namespace.

URI

URI stands for Uniform Resource Identifier. It is a string of characters that identifies a specific resource, such as a webpage, a file, or a service. A URI provides a way to uniquely identify and locate resources by using a standardized format.

A URI consists of two main components:

  1. Scheme: It indicates the protocol or scheme used to access the resource. Examples of common schemes include HTTP (Hypertext Transfer Protocol), HTTPS (HTTP Secure), FTP (File Transfer Protocol), and file (for local file systems).
  2. Resource Identifier: It identifies the specific resource being accessed or referenced. The format of the resource identifier depends on the scheme being used.

Syntactically, URIs mostly follows the same format as that of URLs which is RFC 3986.

However, while URLs allow you to locate a resource, a URI simply identifies a resource. This means that a URI is not necessarily intended as an address to get a resource. It is meant just as an identifier.

If you say you ate at the only Italian restaurant in your city, you are not giving directions on how to get there. However, this information identifies the Italian restaurant among the others in your city.

On the other hand, a URL is a URI. Beyond the fact that it uses the same URI syntax, it also identifies a resource through an address. In other words, a URL is an identifier that allows you to identify a resource and, at the same time, gives you directions to access it.

Here are a few examples of URIs:

  1. URL (Uniform Resource Locator):
    https://www.example.com/index.html
    http://api.example.com/data
    — ftp://ftp.example.com/files/document.pdf
    — mailto:info@example.com
    — mailto:user@example.com?subject=Hello&body=Hi%20there
  2. URN (Uniform Resource Name):
    urn:isbn:0–486–27557–4
    — urn:ietf:rfc:3986
    — urn:oid:2.16.840
  3. Data URI:
    — data:text/plain;base64,SGVsbG8gV29ybGQh
    — data:image/jpeg;base64,/9j/4AAQSkZJRgAB…
  4. Tel URI (for telephone numbers):
    — tel:+1234567890
    — tel:555–123–4567
  5. File URI:
    — file:///path/to/file.txt
    — file:///C:/Documents/document.docx

In summary, while URI is a general term encompassing all types of resource identifiers, URL and URN are specific subtypes of URIs

Relationship between URI, URN and URL

Signing Off!!

Finishing off with the article here. I really hope, I made the article worth your while and you learned a great deal from it.

More than happy to address any improvements and suggestions. Please feel free to drop a comment.

Connect with me via: LinkedIn | Twitter

--

--