What is URL encoding?
URLs can only contain a limited set of characters. When a URL contains spaces, symbols, or non-ASCII characters, those characters must be "percent-encoded" — replaced with a % sign followed by two hex digits representing the character code.
For example, a space becomes %20, an ampersand becomes %26, and a plus sign becomes %2B.
When do you need URL encoding?
- Query parameters — values in query strings must be encoded:
?name=John%20Doe - Form submissions — form data sent via GET is URL-encoded automatically by browsers
- API requests — when building API URLs programmatically, encode parameter values
- UTM parameters — campaign names with spaces or special chars need encoding in URLs