Skip to main content
ToolNara
developer5 min read2026-09-02

URL Percent Encoding Guide: RFC 3986 vs application/x-www-form-urlencoded

Understand URI component encoding, reserved vs unreserved characters, space encoding standards (%20 vs +), and query string safety.

RJRana JawadPrincipal Systems Architect
URLHTTPRFC 3986WebDevelopment

Key takeaways

  • Percent-encoding replaces unsafe or reserved characters with a percent sign (%) followed by two hexadecimal digits representing the UTF-8 byte value.
  • RFC 3986 reserves characters like ?, &, =, and / for URL structure. When used as data values, they must be encoded.
  • Spaces are encoded as %20 in standard URI components, but as + in traditional HTML form submissions (application/x-www-form-urlencoded).
  • Double encoding is a common bug: encoding a string that is already percent-encoded turns %20 into %2520.

Companion utility

Try URL Encoder & Decoder (with Query Inspector)

Use the browser utility for the same task, then return here for the implementation details.

Open tool

1. Why Percent Encoding Is Required

Uniform Resource Identifiers (URIs) are constrained by strict syntax rules. Certain characters have reserved syntactic meanings: '?' introduces query parameters, '&' separates key-value pairs, '=' assigns values, and '/' separates directory paths. If a user search query contains any of these characters (for example, searching for "C++ & Python?"), transmitting those raw characters breaks the URL parser. Percent encoding converts them into safe hexadecimal byte representations.

2. The Classic Question: %20 vs + for Spaces

Developers frequently ask why spaces are sometimes represented as '%20' and other times as '+': - RFC 3986 (URI Standard): Encodes space strictly as '%20'. This is the standard used by modern REST APIs, JavaScript's encodeURIComponent(), and URL paths. - HTML Form Post (application/x-www-form-urlencoded): Historically encoded spaces as '+' signs. While many web servers accept '+' inside query strings, using '%20' avoids ambiguity across different server implementations.

Advertisement
Advertisement placement reserved for editorial content
RJ

Rana Jawad

Principal Systems Architect at ToolNara. The guides focus on browser runtime behavior, standards, and engineering trade-offs.

View author profile

Related guides

Back to all guides