Encode special characters for URLs or decode percent-encoded strings.
URL encoding replaces unsafe characters with % followed by two hex digits. Spaces become %20, ampersands become %26. This ensures URLs work correctly when they contain special characters.
encodeURI encodes a full URL but preserves characters like :, /, ?, #, &. encodeURIComponent encodes everything except letters, digits, and - _ . ~. Use encodeURIComponent for query parameter values.