What is URL encoding?+
URL encoding replaces unsafe characters with a % followed by two hexadecimal digits. For example, a space becomes %20, & becomes %26, and = becomes %3D.
When should I URL-encode my data?+
Always encode values being placed in URL query parameters. This prevents characters like &, =, and # from being interpreted as URL structure rather than data.
What is the difference between encodeURI and encodeURIComponent?+
encodeURI encodes a full URL but leaves reserved characters (like /, ?, &, =) intact. encodeURIComponent encodes everything including reserved characters - use it for individual query parameter values.
Why does a space become %20 in some places and + in others?+
%20 is the standard URL encoding for a space per RFC 3986. The + sign for spaces is an older convention from HTML form encoding (application/x-www-form-urlencoded) and should only be used in that context.