Although in some cases a Uniform Resource Identifier (URI) and a Uniform Resource Locator (URL) may be used interchangeably, they are not the same.

Knowing the difference between a URI and a URL can make your website development easier. For example, you will be able to design a REST API more easily, as a URI or URL will identify every resource on the web.

In short, the main difference between a URI and a URL is that the former can be a name, a location or both, while the latter only provides the location of a resource.

In this article, we will explain in more detail the differences between a URI and a URL and their structure. In addition, we will include use cases for both a URI and a URL along with their pros and cons.

What is a URI?

A URI or Uniform Resource Identifier is a string of characters that generally identifies any web resource by a name, a location, or both. A Uniform Resource Locator (URL) and a Uniform Resource Name (URN) are the two types of URIs.

How to differentiate one from the other

See the following comparison table for a better understanding of the main differences between a URI and a URL.

URI is an acronym for Uniform Resource Identifier.URL is an acronym for Uniform Resource Locator.
URI is the superset of a URN and a URL. URL is the subset of URI.
The URI identifies a resource and differentiates it from others by a name, a location, or both.The URL identifies the web address or location of a unique resource.
The URI contains components such as schema, authority, path and query.The URL has similar components to a URI, but its authority consists of a domain name and a port.
An example of a URI is ISBN 0-476-35557-4.An example of a URL would be
URIs are often used in XML, tag library files and other files such as JSTL and XSTL. The URL is mainly used to search for web pages on the Internet.
The URI scheme can be a protocol, a specification or a designation such as HTTP, file or data. The URL scheme is a protocol, such as HTTP and HTTPS.

Types of URIs

After knowing the main differences between a URI and a URL, let’s focus on the two types of URIs in detail.

Uniform Resource Name (URN)

A URN is a persistent, location-independent identifier that is intended to identify a resource permanently. This means that the resource remains valid even if its data is moved to another location.

To achieve this, a URN uses the schema to distinguish resources. For example, urn:isbn:0405999832 identifies a book by ISBN numbers.

Every Uniform Resource Name (URN) consists of at least three components:

  • URN: each URN uses the prefix urn: schema specification.
  • NID: refers to a namespace identifier that must be registered with the Internet Assigned Numbers Authority (IANA). It can include letters, digits or a hyphen followed by a colon.
  • NSS: is a namespace-specific string that identifies the Internet resource. It can contain ASCII codes, digits, punctuation marks and special characters.

Uniform Resource Locators (URLs)

A URL specifies the method of obtaining a representation of the physical location by describing the primary access mechanism or its location on the network. The resources it attempts to locate can be a web page, a video, an image or any document published online.

Unlike a URN, this Internet resource identifier is not always persistent and location-independent as it specifies the path to the resource, which may change over time. In addition, a URL does not follow the URN scheme.

The main difference between the two identifiers is that a URN only specifies the name of a resource, whereas a URL needs the access technique or protocols to retrieve the location of the resource.

In short, all URLs are URIs, but not all URIs are URLs.