What is URL encoding?
URLs can only contain certain characters. Spaces, accented letters, emoji and symbols like &, ? or # must be "percent-encoded". A space becomes %20, and é becomes %C3%A9. Decoding turns them back into readable text.
Which mode should I use?
- Encode everything (
encodeURIComponent) for a single value you'll put inside a query string, like a search term or a redirect URL. - Keep URL structure (
encodeURI) for a whole URL. It leaves:/?&=#alone so the link still works.
What does "spaces as +" mean?
HTML forms encode spaces as + instead of %20. Tick it when working with form data.