What is URL encoding
URL encoding (percent-encoding) converts special characters, spaces and accented letters into %XX sequences, so they can safely be used inside a URL. For example, a space becomes %20.
When to use it
Needed when building URLs with query parameters that contain spaces, accents or symbols like &, ?, # — without it, the URL can break or be misread by the browser or server.
Input and output examples
café au laitbecomescaf%C3%A9%20au%20lait, because "é" takes two bytes in UTF-8 (C3 A9).a&b=cbecomesa%26b%3Dc, so the & and = are not read as separators.
Space: %20 or +?
HTML form data in a query string often shows a space as +, while in the path portion %20 is the correct form. A literal plus sign, as in "C++", must become %2B, and some decoders will not turn + back into a space on their own.
Double encoding
Encoding text that is already encoded turns % into %25, so %20 becomes %2520. If a URL arrives with %25 sequences in it, decode it one more time to reach the original text.
What does not need encoding
Letters, digits and the symbols - _ . ~ pass through untouched. Characters such as / ? # & = : must be encoded when they belong to a parameter value, but not when they act as the URL's own separators. Encode each value on its own rather than the whole URL, or the :// in https:// also becomes %3A%2F%2F.
Frequently asked questions
Why do I need to encode a URL?
Because some characters have special meaning in URLs (like &, ?, #, space) and need to be converted so they don't break the link.
Is this the same as Base64?
No — they're different encodings for different purposes. URL encoding is specific to web addresses.