What is URL encoding (percent-encoding)?
Short answer
URL encoding, also called percent-encoding, replaces characters that are unsafe or reserved in a URL with a percent sign followed by their hex byte value. A space becomes %20 and an ampersand becomes %26, so the URL stays unambiguous.
Why it is needed
Some characters have a special job inside a URL. A ? starts the query, an & separates parameters, and a space cannot appear at all. If a value legitimately contains one of these, it must be encoded so it is read as data, not structure.
search term: fish & chips
encoded: ?q=fish%20%26%20chipsHow it works
Each reserved or unsafe character is replaced with % followed by the two-digit hexadecimal value of its byte. Space is byte 0x20, so it becomes %20; an ampersand is 0x26, so it becomes %26. Non-ASCII characters are first encoded as UTF-8 bytes, then each byte is percent-encoded.
?, &, or / that form the structure would break the URL.