ToolsBlogWhat is URL Encoding? RFC 3986 Explained

What is URL Encoding? RFC 3986 Explained

Understand the mechanics of URL encoding (Percent-encoding), the reserved characters of RFC 3986, and why it is essential for web security and data transmission.

GoodParse Team
5 min read

Quick Answer: URL Encoding (Percent-encoding) is a mechanism used to safely transmit special characters within a URL. It replaces unsafe or reserved characters (like spaces, ?, or &) with a % followed by their two-digit Hexadecimal equivalent, ensuring the web server processes the URL correctly.

Uniform Resource Locators (URLs) are the addresses of the web, but they have a strict limitation: they can only be sent over the Internet using the US-ASCII character-set. If you want to include a space, a non-English character (like é or ), or a symbol that has special meaning in HTTP (like & or =), you must encode it.

The RFC 3986 Standard

The rules for what must be encoded are defined by the Internet Engineering Task Force (IETF) in RFC 3986. This document divides all characters into two categories:

1. Unreserved Characters

These are characters that are entirely safe to use in a URL without encoding. They include:

  • Alphabet letters: A-Z, a-z
  • Numbers: 0-9
  • Safe symbols: - (hyphen), _ (underscore), . (period), ~ (tilde)

2. Reserved Characters

These characters have a special purpose in URL syntax. If you want to use them as literal data (like inside a search query parameter), they must be encoded:

  • ? (marks the start of the query string) → %3F
  • & (separates query parameters) → %26
  • = (assigns values to parameters) → %3D
  • # (fragment identifier) → %23
  • Space character → %20 (or + in some contexts)

Common Mistakes in JavaScript

Developers often get confused between JavaScript's two built-in encoding functions:

  • encodeURI(): Used for encoding a full, functional URL. It ignores reserved characters that belong in a URL like :// or ?.
  • encodeURIComponent(): Used to encode just the value of a query parameter. It aggressively encodes almost everything, including / and ?, ensuring the value doesn't accidentally break the URL structure.

If you are ever unsure how a string will look when encoded, or need to manually decode a messy URL parameter to read its contents, use our URL Encoder / Decoder tool for instant, safe conversions.

We use cookies to serve personalized ads and analyze traffic. By clicking "Accept", you consent to our use of cookies.