What is the difference between a URI, a URL, and a URN?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
URI, URL, and URN are related terms, but they are not synonyms. The clean way to think about them is that a URI is the broad category, while URL and URN are two different ways of identifying a resource.
URI Is the Umbrella Term
A URI, or Uniform Resource Identifier, is any identifier for a resource. That resource might be a web page, an API endpoint, a book, an email target, or something else entirely.
Examples of URIs include:
- '
https://example.com/docs/install' - '
mailto:[email protected]' - '
urn:isbn:9780134685991'
The important point is that both URLs and URNs are URIs. URI is the generic term, not a competing concept.
URL Identifies by Location
A URL, or Uniform Resource Locator, identifies a resource by telling you where it is or how to access it. That is why web addresses are normally URLs.
Examples:
- '
https://example.com/products/42' - '
ftp://ftp.example.com/files/report.csv'
These identifiers include enough information for a client to attempt retrieval through a scheme such as https or ftp.
In JavaScript, the distinction is reflected in the standard URL API:
This object model is built around locators, which is why a normal browser address is best described as a URL.
URN Identifies by Name
A URN, or Uniform Resource Name, identifies a resource by name rather than by current location. A URN is meant to stay meaningful even if the place where the resource can be found changes.
Examples:
- '
urn:isbn:9780134685991' - '
urn:ietf:rfc:3986'
Those strings tell you what the resource is, not where it is hosted. A separate resolver may turn that name into a location, but the URN itself is not the location.
That is the practical distinction:
- a URL emphasizes access
- a URN emphasizes identity
Why the Terms Get Mixed Up
In everyday web development, people say "URL" for almost everything because most identifiers they handle are HTTP or HTTPS addresses. That is usually fine in casual conversation.
The confusion starts when a specification, parser, or API uses the broader term URI. Libraries often do this because they accept any syntactically valid resource identifier, not only fetchable web locations.
For example, Java uses URI as the general-purpose type:
That makes sense because mailto: is a URI, but it is not the kind of locator that a browser uses like a normal web URL.
A Simple Containment Rule
The relationship can be summarized like this:
- every URL is a URI
- every URN is a URI
- not every URI is a URL
- not every URI is a URN
That rule is more reliable than many oversimplified diagrams.
When Precision Matters
If your API accepts only HTTPS addresses, calling the parameter a URL is clearer than calling it a URI. If your code accepts mailto:, urn:, and https: values, URI is the better name.
So the choice is not about sounding formal. It is about describing the accepted identifier set accurately.
Common Pitfalls
- Saying "every URI is a URL" is incorrect because URNs are URIs too.
- Assuming a valid URI must be retrievable over the network ignores schemes such as
mailto:andurn:. - Treating
URLas the most precise word in every context can make API documentation misleading. - Overcorrecting and calling every web address a
URIcan make ordinary documentation less readable whenURLis the clearer term. - Confusing the resource with a fragment inside it, such as
#intro, leads to mistaken explanations of what is being identified.
Summary
- '
URIis the broad category for resource identifiers.' - '
URLis a URI that identifies a resource through its location or access mechanism.' - '
URNis a URI that identifies a resource by name rather than location.' - Every URL and every URN is a URI.
- Use the most specific term that accurately matches what your code or documentation accepts.

