Component or full URL?
| Mode | Escapes | Use it for |
|---|---|---|
component (encodeURIComponent) |
everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ) |
one query value or path segment |
full URL (encodeURI) |
the same, but keeps : / ? # [ ] @ ! $ & ' ( ) * + , ; = |
a whole URL that must stay a working URL |
Encoding a whole URL with component turns https:// into https%3A%2F%2F; use that only when the URL itself is a parameter value (a redirect target, for example).
Decoding treats + as a space, as HTML forms and application/x-www-form-urlencoded do.
URL parts
Any valid absolute URL, on either side, is parsed with the browser’s URL API. Edit, add or remove query parameters and the encoded URL is rebuilt.