$ url-encode
URL Encoder / Decoder
Percent-encode text for URLs or decode an encoded string. Choose between full-string and component encoding.
Ad slot
Which mode should I use?
Component (encodeURIComponent) is what you want for a single value going into a query string — it encodes &, =, / and ? so they cannot break the URL structure.
Full URI (encodeURI) leaves URL structure characters alone and only escapes spaces and non-ASCII, which is right when you have a whole URL that is mostly fine already.