What Is URL Encoding? Percent-Encoding & RFC 3986 Explained
Learn what URL encoding (percent-encoding) is, why URLs require character escaping, reserved vs unreserved characters, and how query strings are safely transmitted.
Why Do URLs Require Encoding?
A Uniform Resource Identifier (URI) defined under RFC 3986 can only contain a limited set of ASCII characters. Characters like spaces, quotation marks, ampersands, and non-ASCII Unicode letters can corrupt URL routing or clash with structural delimiters (like ?, &, and /).
Reserved vs. Unreserved Characters
- Unreserved Characters (Never Encoded):
A-Z,a-z,0-9,-,_,.,~ - Reserved Characters (Delimiters):
:,/,?,#,[,],@,!,$,&,',(,),*,+,,,;,=
The Percent-Encoding Mechanism
Each forbidden character is converted to its UTF-8 byte representation, followed by a percent sign (%) and the two-digit hexadecimal byte value. For example, a space (ASCII 32, hex 20) becomes %20.