Developer guide
URL Encoding Explained
See why URLs encode spaces and symbols, and how to safely build query parameters.
URL encoding converts characters into a form that can safely travel inside a URL. It is especially important for query values that contain spaces, punctuation, or non-ASCII characters.
What gets encoded
Reserved characters have meaning in a URL, while spaces and many non-ASCII characters need a transport-safe representation. Percent encoding represents a byte with a percent sign and two hexadecimal digits.
Encode values, not the whole URL
When building a query string, encode each parameter value before joining it to the URL. Encoding an already structured URL can change separators such as ?, &, and / and break navigation.
Decode at the right boundary
Decode values when your application receives them, using the URL API or a trusted library. Avoid hand-replacing percent sequences because edge cases are easy to miss.
Put it into practice
Encode a URL