0% completed
URL vs. URI vs. URN
On This Page
URI (Uniform Resource Identifier)
URL (Uniform Resource Locator)
URN (Uniform Resource Name)
The Difference in One Line Each
When It Actually Matters
Three terms, used loosely, that actually sit in a hierarchy.
URI is the umbrella. URL and URN are the two things under it.
URI (Uniform Resource Identifier)
A URI is the general term for anything that identifies a resource, whether by location, by name, or by both. It is the universal identifier.
All URLs and URNs are URIs. Not every URI is a URL or a URN.
That sentence is the whole relationship, and it is what the other two definitions hang off.
URL (Uniform Resource Locator)
A URL is a URI that identifies a resource and tells you how to reach it, by describing its access mechanism, usually its network location.
A URL is typically made of:
- a protocol, such as HTTP, HTTPS or FTP
- a domain name
- a path
- optionally, query parameters or a fragment identifier
For example: https://www.example.com/path?query=term#section
So a URL answers two questions: how do you get the resource, and where is it.
URN (Uniform Resource Name)
A URN is a URI that names a resource without saying how to locate it. It gives a unique and persistent identifier.
For example, urn:isbn:0451450523 identifies a particular book by its ISBN. That identifier holds no matter where a copy of the book happens to be stored, or whether it is stored anywhere at all.
A URN answers one question: what is this thing. It deliberately says nothing about where.
The Difference in One Line Each
| What it does | Answers | |
|---|---|---|
| URI | Identifies a resource, by location or by name | The umbrella over both |
| URL | Identifies a resource and locates it | How and where |
| URN | Names a resource persistently | What |
That also explains the sentence people find confusing. Every URL is a URI, because locating something is one way of identifying it. Not every URI is a URL, because a URI can be a name-only identifier, a URN, which gives no location at all.
When It Actually Matters
Browsing the web, you are dealing with URLs almost all the time, and the distinction rarely comes up.
It matters when something needs an identifier that outlives its location. A digital library that needs to identify a book so the identifier stays valid no matter where the file is stored or moved wants a URN, precisely because a URN names the resource and says nothing about where it currently sits. A URL would break the moment the file moved.
💡 The practical version of this in system design is deciding what an API returns as an identifier. Returning a URL couples every client to your current URL structure. Returning a stable id and letting clients construct the URL keeps that freedom, and this is the distinction underneath that choice.
Key takeaway: A URI is the umbrella term for anything that identifies a resource. A URL is a URI that also locates the resource, made of a protocol, a domain and a path with optional query parameters and a fragment. A URN is a URI that names a resource persistently and says nothing about where it is. Every URL and every URN is a URI, but not every URI is a URL.
The last lesson, What Happens When You Type a URL into the Browser, puts every piece of this chapter into the order it actually runs in.
Abdullah
· 2 years ago
Is mongodb://localhost:27018/xyz a URL or URI?
mdusan
· 9 months ago
What's the significance of the book The Last Unicorn by Peter S. Beagle in this context? URN example is using its isbn,
On This Page
URI (Uniform Resource Identifier)
URL (Uniform Resource Locator)
URN (Uniform Resource Name)
The Difference in One Line Each
When It Actually Matters