Difference between URI, URL and URN

It has been my observation that many of the tech engineers do not know the difference between URI, URN and URLs. For many of them, they are same. For very of them, rest of them and few others are confused. So through this blog post, I intend to clarify that difference. I guess this is more of the classical questions like what to formally call a web address and what do you mean by a web address in first place. In this age of varying protocols and APIs and methods, what is called as a web address is itself of a question. for example, ftp://files.metavrs.in may serve entirely different content than http://files.metavrs.in which may further differ that mailto:files.metavrs.in (these urls are just for understanding purposes only).

There are 3 main components at place: URI, URL and URN. Here’s an exerpt from Tim Berners-Lee, et. al. in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax:

A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.

A URI can be further classified as a locator, a name, or both. The term “Uniform Resource Locator” (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network “location”).

Wikipedia captures this well with the following simplification:

One can classify URIs as locators (URLs), or as names (URNs), or as both. A Uniform Resource Name (URN) functions like a person’s name, while a Uniform Resource Locator (URL) resembles that person’s street address. In other words: the URN defines an item’s identity, while the URL provides a method for finding it.

So we get a few things from these descriptions:

First of all , a URL is a type of URI. So if someone tells you that a URL is not a URI, he/she is wrong. But that doesn’t mean all URIs are URLs. The part that makes a URI a URL is the inclusion of the “access mechanism”, or “network location”, e.g. http:// or ftp://.  The URN is the “globally unique” part of the identification; it’s a unique name. In simple terms, it can be put like this:

Difference between URI, URL and URN
Difference between URI, URL and URN

So out of, http://files.metavrs.in, files.metavrs.in is URN, http://files.metavrs.in is both URL and URI at same time. Also, urn:oasis:names:specification:docbook:dtd:xml:4.1.2 is just a URI, not a URL because it does not refer to a network location at all. In a nutshell, not all URIs are URLs and its a bigger set of URNs and URLs.

Now, what would you prefer to call http://files.metavrs.in, which is both a URI and URL at same time. In my opinion, it would be best to call as URL, because it specifically defines access method and network location. But in the end of the day, its your choice.

One thought on “Difference between URI, URL and URN

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s