URL vs URI vs URN: Key Differences Explaineds

Published: 2023-02-04
6 min read
Share:

If you've worked with REST APIs, web applications, or networking concepts, you've probably encountered the terms URL, URI, and URN. Many developers use them interchangeably, but they are not exactly the same thing.

Understanding URL vs URI vs URN helps when reading technical documentation, designing APIs, preparing for interviews, or working with web standards. While the distinction rarely affects implementation, it is important to understand what each term actually means and how they relate to one another.

Before diving in, it helps to understand how resources are identified on the web and how technologies like REST API and HTTP rely on these identifiers.

What Is a URI?

A URI (Uniform Resource Identifier) is the broadest term of the three.

A URI is a string of characters that identifies a resource. The resource might be a web page, image, document, API endpoint, email address, or any other entity that can be identified.

Examples of URIs:

https://example.com/users/123
mailto:admin@example.com
urn:isbn:9780132350884

Key points:

  • Every URL is a URI.
  • Every URN is a URI.
  • A URI does not necessarily tell you where a resource is located.
  • A URI simply identifies a resource.

In API development, resources are typically identified using URIs. If you're learning REST concepts, understanding what a resource in REST API represents will make URI usage much clearer.

Why Developers Often Say URL Instead of URI

Most developers casually refer to every resource identifier as a URL.

For example, API documentation may say:

https://api.example.com/users/123

Technically, this is both a URI and a URL.

In day-to-day development, saying "URL" is usually acceptable. However, official standards often use the more precise term "URI."

What Is a URL?

A URL (Uniform Resource Locator) is a specific type of URI that tells you both:

  • What the resource is
  • Where the resource is located

A URL provides the information needed to retrieve a resource.

Example:

https://api.example.com/users/123

This URL contains:

  • Scheme: https
  • Host: api.example.com
  • Path: /users/123

Unlike a generic URI, a URL provides the location of the resource and the protocol used to access it.

This is why URLs are fundamental to web browsing and API communication. Every time a client sends a request to a REST endpoint, it uses a URL to locate the target resource. If you're new to this topic, see how REST APIs use HTTP to exchange requests and responses.

Common URL examples:

https://techalmirah.com
https://api.example.com/v1/products
ftp://files.example.com

What Is a URN?

A URN (Uniform Resource Name) is another type of URI.

Unlike a URL, a URN identifies a resource using a unique and persistent name rather than a location.

A URN answers:

What is this resource?

It does not answer:

Where can I find this resource?

Examples:

urn:isbn:9780132350884
urn:ietf:rfc:3986

The first URN identifies a book through its ISBN number.

The second identifies the RFC document that defines URI syntax.

The goal of a URN is to provide a stable identifier that remains valid even if the resource moves to a different location.

URL vs URI vs URN: Key Differences Explained

The relationship is simple:

  • URI is the parent category.
  • URL is a type of URI.
  • URN is a type of URI.

Think of it this way:

  • URI = Identifier
  • URL = Identifier + Location
  • URN = Identifier + Permanent Name

Examples:

URI:
mailto:support@example.com

URL:
https://example.com/products

URN:
urn:isbn:9780132350884

All URLs are URIs.

All URNs are URIs.

Not all URIs are URLs.

Not all URIs are URNs.

A Simple Real-World Analogy

A simple analogy makes the differences easier to remember.

Imagine a person:

  • URI = Anything that uniquely identifies that person
  • URL = Their home address
  • URN = Their permanent government-issued identification number

The home address may change.

The identification number remains the same.

That's similar to how URLs and URNs differ.

Real-World Examples Developers Encounter

Example 1: Website Address

https://techalmirah.com

This is:

  • A URI
  • A URL

It identifies a resource and tells you where to find it.

Example 2: API Endpoint

https://api.example.com/users/123

This is:

  • A URI
  • A URL

This endpoint identifies a resource and provides its location.

Understanding endpoint structure becomes easier when you understand the anatomy of a REST API request.

Example 3: ISBN Number

urn:isbn:9780132350884

This is:

  • A URI
  • A URN

It identifies a book but does not tell you where the book is located.

Example 4: Email Address

mailto:admin@example.com

This is a URI.

It identifies an email destination but is not a traditional web URL.

Why This Matters for REST APIs

When working with APIs, you'll frequently see terms such as:

  • Resource URI
  • Endpoint URL
  • Base URL

Many API design guides use "URI" because it is technically more precise.

For example:

GET https://api.example.com/users/123

The resource is identified through a URI, and the client accesses it through a URL.

Understanding this distinction helps when reading API specifications, debugging requests, and reviewing technical documentation.

If you're still building your REST fundamentals, these guides may help:

URI Standards and RFC 3986

The official syntax and structure of URIs are defined by the RFC 3986 specification published by the Internet Engineering Task Force (IETF).

RFC 3986 defines:

  • URI syntax
  • URI components
  • Parsing rules
  • Normalization rules
  • URI scheme conventions

If you want the authoritative definition of URI, URL, and URN, RFC 3986 remains the primary reference document.

Frequently Asked Questions

Are all URLs URIs?

Yes.

A URL is a specialized form of URI. Every URL is automatically considered a URI.

Are all URIs URLs?

No.

Some URIs are URNs or other identifier formats that do not specify a location.

Are all URNs URIs?

Yes.

A URN is a specific type of URI designed for persistent identification.

Why do developers often confuse URL and URI?

Because most resources used in web applications are both URLs and URIs at the same time.

In practical software development, the distinction is often unnecessary until you encounter standards documentation or protocol specifications.

What are common URI schemes?

Common URI schemes include:

  • https
  • http
  • ftp
  • mailto
  • tel
  • urn

Each scheme defines how the identifier should be interpreted.

Final Thoughts

The easiest way to remember the difference is:

  • URI is the umbrella term.
  • URL identifies and locates a resource.
  • URN identifies a resource using a persistent name.

For most web developers, URLs are the identifiers used daily. However, understanding the broader URI model helps when working with APIs, web standards, networking concepts, and technical specifications.

Free Engineering ToolsNEW

8 free, 100% client-side tools for developers — no signup, no data uploads.

Explore all tools