What percent-encoding is
URLs may only contain a limited set of characters. Anything else — spaces, accented letters, &, ?, # and so on — has to be percent-encoded: each unsafe byte is written as a % followed by its two-digit hexadecimal value (in UTF-8).
So a space becomes %20 and an ampersand becomes %26. Decoding reverses the process. This keeps query strings, paths and form values unambiguous so servers read exactly what you intended.
Worked example
Encoding the query value tax & fees as a component:
%20%26 (otherwise it would start a new parameter).tax%20%26%20fees — safe inside ?q=….Component vs whole URL
Component mode (encodeURIComponent) escapes everything that isn't unreserved, including & / ? # = — use it for a single query value or path segment. Whole-URL mode (encodeURI) leaves the structural characters of a URL intact, so you can encode an entire address without breaking its slashes and separators. Pick component when you're inserting one value into a larger URL.