URL Encoding vs URI Encoding — What's the Real Difference?

"URL encoding" and "URI encoding" are used interchangeably by most developers, and in practice they describe the exact same mechanism: percent-encoding. But the terms aren't actually synonyms at the specification level, and understanding why clears up a lot of confusion around function names like encodeURIComponent.

URI is the broader, correct term

A URI (Uniform Resource Identifier) is any string that identifies a resource — it's defined by RFC 3986. A URL (Uniform Resource Locator) is one kind of URI: specifically one that also tells you how to locate the resource (a scheme + host + path). All URLs are URIs, but not all URIs are URLs.

https://dev-brains-ai.com/blog       ← URL (and also a URI)
mailto:someone@example.com           ← URI, not conventionally called a URL
urn:isbn:9780132350884               ← URI (URN), not a URL — no locator info
tel:+911234567890                    ← URI, not a URL

So what does "encoding" mean for each?

The encoding mechanism itself — percent-encoding — is defined once, in RFC 3986, as part of the URI spec. "URL encoding" isn't a separate algorithm; it's just the same percent-encoding applied to a URL specifically. This is exactly why JavaScript's built-in functions are named with "URI," not "URL" — they operate on the general spec:

encodeURIComponent('a value with spaces & symbols');
// → 'a%20value%20with%20spaces%20%26%20symbols'
// Named "URI" because it implements the RFC 3986 percent-encoding rules,
// applicable to any URI, not just HTTP(S) URLs

Reserved vs unreserved characters

RFC 3986 splits characters into two groups. Unreserved characters — letters, digits, - _ . ~ — never need encoding. Reserved characters have structural meaning (they separate parts of the URI) and must be encoded whenever they appear as literal data rather than as a delimiter.

  • Reserved (structural): / ? # [ ] @ ! $ & ' ( ) * + , ; =
  • Unreserved (never encoded)A-Z a-z 0-9 - _ . ~
  • Everything else (spaces, non-ASCII, most symbols) is always percent-encoded.

Why the distinction matters in practice

When you hear "URL encoding" in casual conversation, in Postman, in a form field, or in most non-spec documentation, treat it as identical to percent-encoding / URI encoding. The only place the distinction genuinely matters is when reading RFCs or writing spec-accurate documentation — pick "URI encoding" for technical precision, "URL encoding" when talking informally about web addresses specifically.

# Python's urllib module also favors "quote" and "url" terminology
from urllib.parse import quote

quote('hello world & more')
# → 'hello%20world%20%26%20more'
# Same percent-encoding, Python just calls the function "quote"

Quick terminology cheat sheet

  • Percent-encoding — the formal, spec-accurate name for the %XX encoding mechanism.
  • URI encoding — same mechanism, described relative to the general URI spec (RFC 3986).
  • URL encoding — same mechanism, described relative to web URLs specifically; the term most developers actually use day to day.
  • All three describe the identical transformation — there is no functional difference to worry about in code.

Frequently Asked Questions

Is URL encoding the same as URI encoding?

Functionally, yes — both terms refer to percent-encoding, the same mechanism of replacing unsafe characters with %XX hex sequences. The difference is terminology: URI is the broader, formally correct term from RFC 3986, while URL refers specifically to web addresses, a subset of URIs.

Why do JavaScript functions use "URI" instead of "URL" in their names?

JavaScript's encodeURIComponent() and encodeURI() are named after URI because that is the technically correct, broader term defined by the relevant RFC. URLs are a specific type of URI, so using "URI" in the API name covers URLs and other URI schemes like urn: or mailto:.

What are reserved characters in a URI?

Reserved characters are symbols like : / ? # [ ] @ ! $ & ' ( ) * + , ; = that have special structural meaning in a URI, such as separating the scheme, host, path, and query. They must be percent-encoded when used as literal data rather than as a delimiter.

Try the Free URL Encoder

See percent-encoding in action — paste any string or URL into our free online tool to encode or decode it instantly.

Related articles