URL vs URI vs URN: What is the Difference
Clear up the relationship between these three identifier specs once and for all.
These three terms get mixed up constantly. The hierarchy is simple once you see it.
The Hierarchy
URI is the umbrella. URL and URN are subsets.
- URI (Uniform Resource Identifier) — any string identifying a resource
- URL (Uniform Resource Locator) — URI that includes how to find the resource
- URN (Uniform Resource Name) — URI that names a resource without saying where it is
Every URL is a URI. Every URN is a URI. URLs and URNs are different kinds of URIs.
URL Examples
https://example.com/page?id=42
ftp://files.example.com/archive.tar
mailto:[email protected]
These tell a client both what the resource is and how to reach it.
URN Examples
urn:isbn:9780201896831
urn:ietf:rfc:3986
urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66
These name something with no location attached. The book ISBN identifies the work; finding it is a separate step.
Anatomy of a URL
scheme://userinfo@host:port/path?query#fragment
https is the scheme. example.com:443 is the authority. /blog/post is the path. Reserved characters in any segment must be percent-encoded.
Common Confusions
- URL with no scheme:
example.com/pageis technically a URI reference, not a URL — though browsers usually accept it. - Encoding:
?and&are reserved in queries but literal in fragments. UseURLSearchParamsto avoid manual encoding mistakes. - Trailing slash:
/blogand/blog/are different URLs. Pick one and 301 the other.
When the Distinction Matters
Most APIs say "URL" when they mean any URI. RFC writers and standards bodies enforce the distinction. For day-to-day code, "URL" is fine; for spec writing, be precise.
Use the [URL Encoder](https://sdk.is/url-encoder) to handle percent-encoding correctly.