Input
Output
Use URL Component for query parameters, form values, or dynamic URL segments, and use Full URL only when you want to encode an already well-formed whole URL [web:554][web:561].
How it works
`encodeURIComponent()` encodes more characters and is the right choice for dynamic parts such as query-string values, while `encodeURI()` is intended for an already assembled full URI and preserves URI syntax characters [web:554][web:561]. On decode, `decodeURIComponent()` reverses percent-encoded sequences, but malformed input can throw a `URIError`, so tools should catch bad sequences gracefully [web:553][web:557][web:560].
- Use URL Component mode for values like names, emails, search queries, or query params [web:554][web:561].
- Use Full URL mode when working with a full URL string that should preserve reserved URL structure characters [web:554].
- Invalid encoded input can trigger a malformed URI error during decoding [web:557][web:562].