How it works
URLs may only contain a limited set of ASCII characters. Everything else — spaces, accented letters, emoji, and characters that have special meaning in URLs like & and ? — must be percent-encoded: converted to UTF-8 bytes and written as % followed by two hex digits. A space becomes %20 and é becomes %C3%A9.
Use component mode for a single piece you are inserting into a URL, such as a search term in ?q=… or one path segment. It encodes the reserved characters / ? & = # so they cannot break the URL structure. Full-URL mode leaves those characters alone and only escapes what is illegal, which is right when you already have a complete address with spaces or non-ASCII characters in it.
HTML forms submitted with application/x-www-form-urlencoded write spaces as + instead of %20. Turn on the + option to produce or read that style. Encoding happens locally in your browser.
Frequently asked questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI assumes you are giving it a whole URL and keeps characters like : / ? & = intact. encodeURIComponent assumes the text is one value and escapes those too. Using encodeURI on a query value is a common bug: an & inside the value would split it into two parameters.
Why does decoding fail with "malformed"?
There is a % not followed by two hex digits, or the bytes do not form valid UTF-8 — often a sign the text was encoded with an old Latin-1 encoder or is already decoded and contains a literal % sign.
Should I encode a URL twice?
No. Double encoding turns %20 into %2520, which servers will read as the literal text "%20". Encode each value once, right before building the URL.