Jun
28
2023

URL vs URI vs URN

url-vs-uri-vs-urn-cover

URL, URI, and URN are all related to addressing resources on the internet, but they have different meanings and purposes. Here’s an explanation of each term:

1. URL (Uniform Resource Locator):
A URL is a specific type of URI that identifies the location of a resource on the web. It includes the protocol, domain name, and optional path, query parameters, and fragment identifier. URLs are commonly used to access web pages, files, and other resources on the internet. They are typically structured as follows:

protocol://domain/path?query#fragment

For example:
https://www.example.com/index.html?id=123#section2

In the example, the URL points directly to the specific resource on the web:

https://www.example.com/index.html?id=123#section2

2. URI (Uniform Resource Identifier):
A URI is a broader concept that encompasses both URLs and URNs. It is a string of characters used to identify or name a resource, regardless of its location. URIs are divided into two subcategories: URLs and URNs. A URI can be used to retrieve the resource (URL) or provide a unique identifier (URN) for the resource. URIs are used to identify various resources, including web pages, images, APIs, and more.

In the example, the URI represents the general identifier for the resource, but it may not directly point to its location:

uri:example123

3. URN (Uniform Resource Name):
A URN is a specific type of URI that provides a unique, persistent name for a resource. Unlike URLs, URNs are not location-dependent and are intended to remain valid even if the resource changes its location over time. URNs are typically used to provide long-term, stable identification for resources, such as books, articles, or other digital objects. URNs have a hierarchical structure, with a namespace identifier and a unique name.

In the example, the URN represents a persistent and unique name for the resource, independent of its location:

urn:example123

To summarize, URLs are a specific type of URI that provide the location of a resource on the web. URIs encompass both URLs and URNs, with URNs providing unique and persistent names for resources, independent of their locations.