DEV Community

Robertino
Robertino

Posted on • Originally published at auth0.com

URL, URI, URN: What's the Difference?

Let's try to shed some light on the differences between URL, URI, and URN.


While most developers know what a URL is, not everyone knows what a URI is, and even less knows about URNs. Not to mention that the relationship between these items is not always very clear. Let's clarify in simple words the difference.

What Is a URL?

We have to deal with URLs every day. URL is an acronym that stands for Uniform Resource Locator. Maybe the expanded name may sound weird, but you can simply call it address. The term address explains very well the role of a URL. You can think of a URL like your home address: it contains all the information to find your home.

Similarly, you can define a URL as a string that denotes the location of a given resource on the Internet: a web page, an image, a mailbox, etc. The following are examples of URLs:

https://jwt.io
https://auth0.com/docs/get-started#learn-the-basics
https://identicons.dev/static/icons/mono/png/icon-access-token.png
mailto:yourfriend@somewhere.com
ftp://ftpserver.com/myfolder
Enter fullscreen mode Exit fullscreen mode

URLs and links

While the terms URL and link are commonly used interchangeably, technically they are not synonyms. A URL is a string that allows you to locate a resource. A link (short for hyperlink) is an HTML element that enables you to load a resource from a given URL in a browser. So, a link relies on a URL, and a URL can exist without a link, but a link without a URL makes no sense (at least in its original meaning).

Anatomy of a URL

The Uniform part of the URL acronym is about a common structure of these locator strings. The following image shows this standard structure:

Structure of a URL with all its parts

An URL consists of the following parts:

  • Scheme: in a URL, this is the protocol that should be used to access the resource. Beyond the well-known HTTP and HTTPS, you can use many other schemes.
  • Domain: this part indicates the server hosting the resource. It can be a domain name or an IP address.
  • Port: it is the protocol port to which to send the request to access the resource. Usually, it is omitted, meaning that the default protocol port should be used.
  • Path: this is the path to the resource on the hosting server.
  • Parameters: these are optional extra information provided to the hosting server.
  • Anchor: this part represents a specific part inside the resource. It is also called fragment.

The group consisting of the domain name and the port, if present, is also known as authority. The scheme and the authority are separated by the string ://. If a URL has no authority, 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:yourfriend@somewhere.com.

Read more...

Top comments (0)