URL Vs URI Vs URN

Lets first look at full form:

UR - Uniform Resource URI - UR Identifier URL - UR Locator URN - UR Name

TLDR

  • URI (uniform resource identifier) identifies a specific resource on the web (for e.g. text document, image file, etc)
  • URL (uniform resource locator) is a subset of the URIs that include a network location. So, it not only identifies a resource but also provides a means of locating it by describing its primary access mechanism ( e.g. network location)
  • URN (uniform resource name) is a subset of URIs that names a resource without implying its location or how it can be accessed. (eg. urn:isbn:0451450523)

Generally,

URI describes Location + Name
URL describes Location
URN describes Name

All URLs Are URIs, but Not Vice-versa

If a URL provides both the location and the name of a resource, it is considered a URI. While URIs serve to identify, URLs specify location; hence, identifying through a location means every URL is also a URI. However, some URIs are not URLs.

  • google.com is a URI as it is solely the name of a resource.
  • https://google.com is a URL because it specifies both the name and how to access the resource.

Examples

The figure below should make things clearer:

URI:       https://www.example.com/books/12345?edition=first
		 └────────────────────────────────────────────────┘ (entire string is URI)

URL:       https://www.example.com/books/12345?edition=first
		 └────────────────────────────────────────────────┘ (also URL since it provides location)

URN:       urn:isbn:12345 (not directly in the URL, but represents a resource identifier)

More Examples

URIsURNsURLs
A name, name and location, or botha name or numbera name/number with location
A name, a name and address, or bothSomeone’s name or addressSomeone’s name and address
An ISBN numberAn ISBN numbermailto://[email protected]
[email protected][email protected]mailto://[email protected]
[email protected]ftp.google.comftp://ftp.google.com

URL

Contains information about how to fetch a resource from its location. For example:

  • http://example.com/mypage.html
  • ftp://example.com/download.zip
  • mailto:[email protected]
  • file:///home/user/file.txt
  • http://example.com/resource?foo=bar#fragment
  • /other/link.html (A relative URL, only useful in the context of another URL)

URLs always start with a protocol (http) and usually contain information such as the network host name (example.com) and often a document path (/foo/mypage.html). URLs may have query parameters and fragment identifiers.

URL Structure

URN

Identifies a resource by name and begins with the prefix urn:. For instance:

  • urn:isbn:0451450523 identifies a book by its ISBN number.
  • urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 serves as a globally unique identifier.
  • urn:publishing:book denotes an XML namespace that classifies the document as a book.

URNs can represent ideas and concepts, not just documents. When a URN does refer to a document, it can be converted into a URL through a “resolver,” allowing the document to be downloaded.

URI

URIs encompass URLs, URNs, and other methods of identifying a resource.

A URI that is neither a URL nor a URN could be a data URI like data:,Hello%20World. This type of URI contains the data directly and neither names it nor provides its network location.

Additionally, there are Uniform Resource Citations (URCs), which refer to metadata about a document instead of the document itself. For instance, view-source:http://example.com/ is a URC that allows viewing the source code of a webpage. URCs are another form of URI distinct from URLs and URNs.

Resources Identifiers

URLs and Resource Identifiers