How Percent-Encoding (URL Encoding) Works
URLs are designed to carry data across specific web architectures. However, certain characters (like space, ?, &, #, %) have specific functional definitions in a URI. If you want to use these characters as plain data parameters, they must be formatted into a safe hexadecimal equivalent prefixed by a percent symbol (%):
Comparison Matrix
Suppose you have the query string parameters: title=Calculent & Co.&id=42
- Encode Component (encodeURIComponent): Escapes characters like
=,&, and spaces. Yields:title%3DCalculent%20%26%20Co.%26id%3D42(Safe to place as a single query parameter). - Encode Full URI (encodeURI): Retains functional syntax like
=and&, escaping only characters like spaces. Yields:title=Calculent%20&%20Co.&id=42(Retains standard parameter structure).
Frequently Asked Questions
Historically, query parameters in HTML forms (application/x-www-form-urlencoded) encode spaces as a plus sign (+). Modern standard RFC 3986 defines spaces as %20, which is globally compliant and robust across both query parameters and path locations.
This error occurs when the percent-decoder encounters a percent character (%) that isn't followed by a valid 2-digit hexadecimal number (e.g. %G1 or a trailing % at the end of the string). To fix this, make sure all percent symbols represent valid escape bytes.
Yes. The entire string replacement and regex percent-mapping takes place fully on the client-side using JavaScript APIs inside your own browser window. No server logging or external analysis is performed.